Move the fs module out of worktree

Max Brunsfeld created

Change summary

server/src/tests.rs      | 3 ++-
zed/src/editor/buffer.rs | 3 ++-
zed/src/file_finder.rs   | 2 +-
zed/src/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(-)

Detailed changes

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};
 

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::*;

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;

zed/src/worktree/fs.rs → 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};

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<language::LanguageRegistry>,
     pub rpc_router: std::sync::Arc<ForegroundRouter>,
     pub rpc: rpc::Client,
-    pub fs: std::sync::Arc<dyn worktree::Fs>,
+    pub fs: std::sync::Arc<dyn fs::Fs>,
 }
 
 pub fn init(cx: &mut gpui::MutableAppContext) {

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;

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},

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};

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;