From 7260442d4272c064ef439909ab65c2cbbef1bf0c Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Tue, 13 Jul 2021 15:37:30 -0700 Subject: [PATCH] Move the fs module out of worktree --- server/src/tests.rs | 3 ++- zed/src/editor/buffer.rs | 3 ++- zed/src/file_finder.rs | 2 +- zed/src/{worktree => }/fs.rs | 2 +- zed/src/lib.rs | 3 ++- zed/src/main.rs | 6 ++++-- zed/src/test.rs | 4 +--- zed/src/workspace.rs | 6 ++++-- zed/src/worktree.rs | 4 ++-- 9 files changed, 19 insertions(+), 14 deletions(-) rename zed/src/{worktree => }/fs.rs (99%) diff --git a/server/src/tests.rs b/server/src/tests.rs index 041a5adcea301910d82539b74c4396120640d4e1..0f35b5161ba4dc0a67a84c2b6e2505c10a2ee3aa 100644 --- a/server/src/tests.rs +++ b/server/src/tests.rs @@ -15,11 +15,12 @@ use sqlx::{ use std::{path::Path, sync::Arc}; use zed::{ editor::Editor, + fs::{FakeFs, Fs as _}, language::LanguageRegistry, rpc::Client, settings, test::Channel, - worktree::{FakeFs, Fs as _, Worktree}, + worktree::Worktree, }; use zrpc::{ForegroundRouter, Peer, Router}; diff --git a/zed/src/editor/buffer.rs b/zed/src/editor/buffer.rs index 6c1a0af436aa8d78fed14272031cc498db863f71..c0ce0af2d7643d663cc0417eb6b0e7e1e490fb11 100644 --- a/zed/src/editor/buffer.rs +++ b/zed/src/editor/buffer.rs @@ -2732,9 +2732,10 @@ impl ToPoint for usize { mod tests { use super::*; use crate::{ + fs::RealFs, test::{build_app_state, temp_tree}, util::RandomCharIter, - worktree::{RealFs, Worktree, WorktreeHandle}, + worktree::{Worktree, WorktreeHandle as _}, }; use gpui::ModelHandle; use rand::prelude::*; diff --git a/zed/src/file_finder.rs b/zed/src/file_finder.rs index 02ea62eaf63030ce2b6c077408f939ca7059d823..2f5ad01101e38c450cf740d6faeaf4a7a463cc43 100644 --- a/zed/src/file_finder.rs +++ b/zed/src/file_finder.rs @@ -457,9 +457,9 @@ mod tests { use super::*; use crate::{ editor, + fs::FakeFs, test::{build_app_state, temp_tree}, workspace::Workspace, - worktree::FakeFs, }; use serde_json::json; use std::fs; diff --git a/zed/src/worktree/fs.rs b/zed/src/fs.rs similarity index 99% rename from zed/src/worktree/fs.rs rename to zed/src/fs.rs index 5dc44ffb49691b96fb0722fa759d8b8b15dfb98a..034e06d7c96d4650c76d2f7f3e98f76f9ef4924c 100644 --- a/zed/src/worktree/fs.rs +++ b/zed/src/fs.rs @@ -1,4 +1,4 @@ -use super::Rope; +use super::editor::Rope; use anyhow::{anyhow, Result}; use fsevent::EventStream; use futures::{Stream, StreamExt}; diff --git a/zed/src/lib.rs b/zed/src/lib.rs index d550c0ee49ef7850321e1d4d3c84e48d6fd81270..efa0dd8288b36e79e425e6f1fd4049f686356cbf 100644 --- a/zed/src/lib.rs +++ b/zed/src/lib.rs @@ -3,6 +3,7 @@ use zrpc::ForegroundRouter; pub mod assets; pub mod editor; pub mod file_finder; +pub mod fs; pub mod language; pub mod menus; mod operation_queue; @@ -21,7 +22,7 @@ pub struct AppState { pub languages: std::sync::Arc, pub rpc_router: std::sync::Arc, pub rpc: rpc::Client, - pub fs: std::sync::Arc, + pub fs: std::sync::Arc, } pub fn init(cx: &mut gpui::MutableAppContext) { diff --git a/zed/src/main.rs b/zed/src/main.rs index 4630f215cbf6918c6b0821b756634b9202be0e8b..d69818a54100faa3b1aa89f13179b1aa950fbc53 100644 --- a/zed/src/main.rs +++ b/zed/src/main.rs @@ -6,9 +6,11 @@ use log::LevelFilter; use simplelog::SimpleLogger; use std::{fs, path::PathBuf, sync::Arc}; use zed::{ - self, assets, editor, file_finder, language, menus, rpc, settings, + self, assets, editor, file_finder, + fs::RealFs, + language, menus, rpc, settings, workspace::{self, OpenParams}, - worktree::{self, RealFs}, + worktree::{self}, AppState, }; use zrpc::ForegroundRouter; diff --git a/zed/src/test.rs b/zed/src/test.rs index c08f65937cb298a5aa81638fdedf116315d200cc..adc75100a0e0be650614c0c73ad45265355f2b83 100644 --- a/zed/src/test.rs +++ b/zed/src/test.rs @@ -1,6 +1,4 @@ -use crate::{ - language::LanguageRegistry, rpc, settings, time::ReplicaId, worktree::RealFs, AppState, -}; +use crate::{fs::RealFs, language::LanguageRegistry, rpc, settings, time::ReplicaId, AppState}; use gpui::AppContext; use std::{ path::{Path, PathBuf}, diff --git a/zed/src/workspace.rs b/zed/src/workspace.rs index 28aea860dca4e891f8a4b77741cc6b69764c2682..4086eddd8230201bad184f70d0750e9a95c9caac 100644 --- a/zed/src/workspace.rs +++ b/zed/src/workspace.rs @@ -3,10 +3,11 @@ pub mod pane_group; use crate::{ editor::{Buffer, Editor}, + fs::Fs, language::LanguageRegistry, rpc, settings::Settings, - worktree::{File, Fs, Worktree}, + worktree::{File, Worktree}, AppState, }; use anyhow::{anyhow, Result}; @@ -921,8 +922,9 @@ mod tests { use super::*; use crate::{ editor::Editor, + fs::FakeFs, test::{build_app_state, temp_tree}, - worktree::{FakeFs, WorktreeHandle}, + worktree::WorktreeHandle, }; use serde_json::json; use std::{collections::HashSet, fs}; diff --git a/zed/src/worktree.rs b/zed/src/worktree.rs index 755bc56720be7a4e841c708ceca5108368bd17d1..ada7af0c18e1386faad8cd02d8ce8f08d3ecd404 100644 --- a/zed/src/worktree.rs +++ b/zed/src/worktree.rs @@ -1,11 +1,11 @@ mod char_bag; -mod fs; mod fuzzy; mod ignore; use self::{char_bag::CharBag, ignore::IgnoreStack}; use crate::{ editor::{self, Buffer, History, Operation, Rope}, + fs::{self, Fs}, language::LanguageRegistry, rpc::{self, proto}, sum_tree::{self, Cursor, Edit, SumTree}, @@ -14,7 +14,6 @@ use crate::{ }; use ::ignore::gitignore::Gitignore; use anyhow::{anyhow, Result}; -pub use fs::*; use futures::{Stream, StreamExt}; pub use fuzzy::{match_paths, PathMatch}; use gpui::{ @@ -2571,6 +2570,7 @@ mod tests { use super::*; use crate::test::*; use anyhow::Result; + use fs::RealFs; use rand::prelude::*; use serde_json::json; use std::time::UNIX_EPOCH;