Moved settings_file.rs into settings crate. Should be ready to start now :D

This commit is contained in:
Mikayla Maki 2022-10-11 16:03:38 -07:00
parent 0beb97547e
commit 5487f99ac7
7 changed files with 20 additions and 12 deletions

3
Cargo.lock generated
View file

@ -5060,8 +5060,11 @@ dependencies = [
"anyhow", "anyhow",
"assets", "assets",
"collections", "collections",
"fs",
"futures",
"gpui", "gpui",
"json_comments", "json_comments",
"postage",
"schemars", "schemars",
"serde", "serde",
"serde_json", "serde_json",

View file

@ -40,7 +40,9 @@ use sum_tree::TreeMap;
use text::operation_queue::OperationQueue; use text::operation_queue::OperationQueue;
pub use text::{Buffer as TextBuffer, BufferSnapshot as TextBufferSnapshot, Operation as _, *}; pub use text::{Buffer as TextBuffer, BufferSnapshot as TextBufferSnapshot, Operation as _, *};
use theme::SyntaxTheme; use theme::SyntaxTheme;
use util::{RandomCharIter, TryFutureExt as _}; #[cfg(any(test, feature = "test-support"))]
use util::RandomCharIter;
use util::TryFutureExt as _;
#[cfg(any(test, feature = "test-support"))] #[cfg(any(test, feature = "test-support"))]
pub use {tree_sitter_rust, tree_sitter_typescript}; pub use {tree_sitter_rust, tree_sitter_typescript};

View file

@ -14,10 +14,13 @@ test-support = []
assets = { path = "../assets" } assets = { path = "../assets" }
collections = { path = "../collections" } collections = { path = "../collections" }
gpui = { path = "../gpui" } gpui = { path = "../gpui" }
fs = { path = "../fs" }
anyhow = "1.0.38"
futures = "0.3"
theme = { path = "../theme" } theme = { path = "../theme" }
util = { path = "../util" } util = { path = "../util" }
anyhow = "1.0.38"
json_comments = "0.2" json_comments = "0.2"
postage = { version = "0.4.1", features = ["futures-traits"] }
schemars = "0.8" schemars = "0.8"
serde = { workspace = true } serde = { workspace = true }
serde_json = { workspace = true } serde_json = { workspace = true }

View file

@ -1,4 +1,5 @@
mod keymap_file; mod keymap_file;
pub mod settings_file;
use anyhow::Result; use anyhow::Result;
use gpui::{ use gpui::{

View file

@ -1,14 +1,16 @@
use fs::Fs;
use futures::StreamExt; use futures::StreamExt;
use gpui::{executor, MutableAppContext}; use gpui::{executor, MutableAppContext};
use postage::sink::Sink as _; use postage::sink::Sink as _;
use postage::{prelude::Stream, watch}; use postage::{prelude::Stream, watch};
use project::Fs;
use serde::Deserialize; use serde::Deserialize;
use settings::{parse_json_with_comments, KeymapFileContent, Settings, SettingsFileContent};
use std::{path::Path, sync::Arc, time::Duration}; use std::{path::Path, sync::Arc, time::Duration};
use theme::ThemeRegistry; use theme::ThemeRegistry;
use util::ResultExt; use util::ResultExt;
use crate::{parse_json_with_comments, KeymapFileContent, Settings, SettingsFileContent};
#[derive(Clone)] #[derive(Clone)]
pub struct WatchedJsonFile<T>(pub watch::Receiver<T>); pub struct WatchedJsonFile<T>(pub watch::Receiver<T>);
@ -77,7 +79,7 @@ pub fn watch_settings_file(
pub fn keymap_updated(content: KeymapFileContent, cx: &mut MutableAppContext) { pub fn keymap_updated(content: KeymapFileContent, cx: &mut MutableAppContext) {
cx.clear_bindings(); cx.clear_bindings();
settings::KeymapFileContent::load_defaults(cx); KeymapFileContent::load_defaults(cx);
content.add_to_cx(cx).log_err(); content.add_to_cx(cx).log_err();
} }
@ -105,8 +107,8 @@ pub fn watch_keymap_file(mut file: WatchedJsonFile<KeymapFileContent>, cx: &mut
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use project::FakeFs; use crate::{EditorSettings, SoftWrap};
use settings::{EditorSettings, SoftWrap}; use fs::FakeFs;
#[gpui::test] #[gpui::test]
async fn test_watch_settings_files(cx: &mut gpui::TestAppContext) { async fn test_watch_settings_files(cx: &mut gpui::TestAppContext) {

View file

@ -32,13 +32,11 @@ use std::{env, ffi::OsStr, panic, path::PathBuf, sync::Arc, thread, time::Durati
use terminal::terminal_container_view::{get_working_directory, TerminalContainer}; use terminal::terminal_container_view::{get_working_directory, TerminalContainer};
use fs::RealFs; use fs::RealFs;
use settings::settings_file::{watch_keymap_file, watch_settings_file, WatchedJsonFile};
use theme::ThemeRegistry; use theme::ThemeRegistry;
use util::{ResultExt, TryFutureExt}; use util::{ResultExt, TryFutureExt};
use workspace::{self, AppState, ItemHandle, NewFile, OpenPaths, Workspace}; use workspace::{self, AppState, ItemHandle, NewFile, OpenPaths, Workspace};
use zed::{ use zed::{self, build_window_options, initialize_workspace, languages, menus};
self, build_window_options, initialize_workspace, languages, menus,
settings_file::{watch_keymap_file, watch_settings_file, WatchedJsonFile},
};
fn main() { fn main() {
let http = http::client(); let http = http::client();

View file

@ -2,7 +2,6 @@ mod feedback;
pub mod languages; pub mod languages;
pub mod menus; pub mod menus;
pub mod paths; pub mod paths;
pub mod settings_file;
#[cfg(any(test, feature = "test-support"))] #[cfg(any(test, feature = "test-support"))]
pub mod test; pub mod test;