From 5487f99ac78bf4bd8ac2dc73d19db2e18757faa8 Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Tue, 11 Oct 2022 16:03:38 -0700 Subject: [PATCH] Moved settings_file.rs into settings crate. Should be ready to start now :D --- Cargo.lock | 3 +++ crates/language/src/buffer.rs | 4 +++- crates/settings/Cargo.toml | 5 ++++- crates/settings/src/settings.rs | 1 + crates/{zed => settings}/src/settings_file.rs | 12 +++++++----- crates/zed/src/main.rs | 6 ++---- crates/zed/src/zed.rs | 1 - 7 files changed, 20 insertions(+), 12 deletions(-) rename crates/{zed => settings}/src/settings_file.rs (96%) diff --git a/Cargo.lock b/Cargo.lock index ebf2d4376c120931a8ee7e9ee8d13c4c08110f2a..fca454f1f8dc497e0195c60bedf80dbfb51c625e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5060,8 +5060,11 @@ dependencies = [ "anyhow", "assets", "collections", + "fs", + "futures", "gpui", "json_comments", + "postage", "schemars", "serde", "serde_json", diff --git a/crates/language/src/buffer.rs b/crates/language/src/buffer.rs index 56aad18eadaeda1885ded1c1f6c9e457225ddce5..a9af41bb23ec08a125cf1738830503b33c2a1a22 100644 --- a/crates/language/src/buffer.rs +++ b/crates/language/src/buffer.rs @@ -40,7 +40,9 @@ use sum_tree::TreeMap; use text::operation_queue::OperationQueue; pub use text::{Buffer as TextBuffer, BufferSnapshot as TextBufferSnapshot, Operation as _, *}; 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"))] pub use {tree_sitter_rust, tree_sitter_typescript}; diff --git a/crates/settings/Cargo.toml b/crates/settings/Cargo.toml index e8fb58cd6196a71872147b174f4aff8db03f93c5..64c906a833eed00a0152b1ed38a97c9113686d6f 100644 --- a/crates/settings/Cargo.toml +++ b/crates/settings/Cargo.toml @@ -14,10 +14,13 @@ test-support = [] assets = { path = "../assets" } collections = { path = "../collections" } gpui = { path = "../gpui" } +fs = { path = "../fs" } +anyhow = "1.0.38" +futures = "0.3" theme = { path = "../theme" } util = { path = "../util" } -anyhow = "1.0.38" json_comments = "0.2" +postage = { version = "0.4.1", features = ["futures-traits"] } schemars = "0.8" serde = { workspace = true } serde_json = { workspace = true } diff --git a/crates/settings/src/settings.rs b/crates/settings/src/settings.rs index 921b36051f0be1868aa799f0325db0f973ea2942..883d7694c75403993d67d687f9d75843c97d7ba8 100644 --- a/crates/settings/src/settings.rs +++ b/crates/settings/src/settings.rs @@ -1,4 +1,5 @@ mod keymap_file; +pub mod settings_file; use anyhow::Result; use gpui::{ diff --git a/crates/zed/src/settings_file.rs b/crates/settings/src/settings_file.rs similarity index 96% rename from crates/zed/src/settings_file.rs rename to crates/settings/src/settings_file.rs index 25bd065b47a701fd32d7371587a7f9fa925caa09..f12f191041d8b6f681d116c672f09e6fefee2d5e 100644 --- a/crates/zed/src/settings_file.rs +++ b/crates/settings/src/settings_file.rs @@ -1,14 +1,16 @@ +use fs::Fs; use futures::StreamExt; use gpui::{executor, MutableAppContext}; use postage::sink::Sink as _; use postage::{prelude::Stream, watch}; -use project::Fs; use serde::Deserialize; -use settings::{parse_json_with_comments, KeymapFileContent, Settings, SettingsFileContent}; + use std::{path::Path, sync::Arc, time::Duration}; use theme::ThemeRegistry; use util::ResultExt; +use crate::{parse_json_with_comments, KeymapFileContent, Settings, SettingsFileContent}; + #[derive(Clone)] pub struct WatchedJsonFile(pub watch::Receiver); @@ -77,7 +79,7 @@ pub fn watch_settings_file( pub fn keymap_updated(content: KeymapFileContent, cx: &mut MutableAppContext) { cx.clear_bindings(); - settings::KeymapFileContent::load_defaults(cx); + KeymapFileContent::load_defaults(cx); content.add_to_cx(cx).log_err(); } @@ -105,8 +107,8 @@ pub fn watch_keymap_file(mut file: WatchedJsonFile, cx: &mut #[cfg(test)] mod tests { use super::*; - use project::FakeFs; - use settings::{EditorSettings, SoftWrap}; + use crate::{EditorSettings, SoftWrap}; + use fs::FakeFs; #[gpui::test] async fn test_watch_settings_files(cx: &mut gpui::TestAppContext) { diff --git a/crates/zed/src/main.rs b/crates/zed/src/main.rs index 6c93ff5ba67c025826e0048443aaf66f446328f3..7dc30d34f54f518a6906973847389016c317d501 100644 --- a/crates/zed/src/main.rs +++ b/crates/zed/src/main.rs @@ -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 fs::RealFs; +use settings::settings_file::{watch_keymap_file, watch_settings_file, WatchedJsonFile}; use theme::ThemeRegistry; use util::{ResultExt, TryFutureExt}; use workspace::{self, AppState, ItemHandle, NewFile, OpenPaths, Workspace}; -use zed::{ - self, build_window_options, initialize_workspace, languages, menus, - settings_file::{watch_keymap_file, watch_settings_file, WatchedJsonFile}, -}; +use zed::{self, build_window_options, initialize_workspace, languages, menus}; fn main() { let http = http::client(); diff --git a/crates/zed/src/zed.rs b/crates/zed/src/zed.rs index a2857f01dc30b281de9e5832c6655bd84fb8ca65..9012bc89e22489b4ce34c193bf5fb91e3810e180 100644 --- a/crates/zed/src/zed.rs +++ b/crates/zed/src/zed.rs @@ -2,7 +2,6 @@ mod feedback; pub mod languages; pub mod menus; pub mod paths; -pub mod settings_file; #[cfg(any(test, feature = "test-support"))] pub mod test;