From 1789dfb8b1c41bc68aaf903f0d4ce640d655c1b1 Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Mon, 17 Oct 2022 14:53:52 -0700 Subject: [PATCH] Fixed tests --- crates/breadcrumbs/src/breadcrumbs.rs | 2 +- crates/collab/src/integration_tests.rs | 6 ++++-- crates/fs/src/fs.rs | 9 +++++++++ crates/project/src/project.rs | 5 ++++- crates/project/src/worktree.rs | 8 ++++++-- crates/terminal/src/terminal_view.rs | 13 +------------ 6 files changed, 25 insertions(+), 18 deletions(-) diff --git a/crates/breadcrumbs/src/breadcrumbs.rs b/crates/breadcrumbs/src/breadcrumbs.rs index b8c66b1f87..a95f1cf4f7 100644 --- a/crates/breadcrumbs/src/breadcrumbs.rs +++ b/crates/breadcrumbs/src/breadcrumbs.rs @@ -47,7 +47,7 @@ impl View for Breadcrumbs { .with_children(Itertools::intersperse_with(breadcrumbs.into_iter(), || { Label::new(" 〉 ".to_string(), theme.breadcrumbs.text.clone()).boxed() })) - .scrollable::(1, None, cx) + .scrollable::(0, None, cx) .contained() .with_style(theme.breadcrumbs.container) .aligned() diff --git a/crates/collab/src/integration_tests.rs b/crates/collab/src/integration_tests.rs index 90d7b6d4b5..debd2d56be 100644 --- a/crates/collab/src/integration_tests.rs +++ b/crates/collab/src/integration_tests.rs @@ -15,7 +15,7 @@ use editor::{ self, ConfirmCodeAction, ConfirmCompletion, ConfirmRename, Editor, Redo, Rename, ToOffset, ToggleCodeActions, Undo, }; -use fs::{FakeFs, Fs as _, LineEnding}; +use fs::{FakeFs, Fs as _, HomeDir, LineEnding}; use futures::{channel::mpsc, Future, StreamExt as _}; use gpui::{ executor::{self, Deterministic}, @@ -3038,7 +3038,7 @@ async fn test_references(cx_a: &mut TestAppContext, cx_b: &mut TestAppContext) { assert_eq!(references[1].buffer, references[0].buffer); assert_eq!( three_buffer.file().unwrap().full_path(cx), - Path::new("three.rs") + Path::new("/OUTSIDE_PROJECT/three.rs") ); assert_eq!(references[0].range.to_offset(two_buffer), 24..27); @@ -6130,6 +6130,8 @@ impl TestServer { async fn create_client(&mut self, cx: &mut TestAppContext, name: &str) -> TestClient { cx.update(|cx| { + cx.set_global(HomeDir(Path::new("/tmp/").to_path_buf())); + let mut settings = Settings::test(cx); settings.projects_online_by_default = false; cx.set_global(settings); diff --git a/crates/fs/src/fs.rs b/crates/fs/src/fs.rs index c1ea6feee5..7bd7346b4b 100644 --- a/crates/fs/src/fs.rs +++ b/crates/fs/src/fs.rs @@ -13,6 +13,7 @@ use smol::io::{AsyncReadExt, AsyncWriteExt}; use std::borrow::Cow; use std::cmp; use std::io::Write; +use std::ops::Deref; use std::sync::Arc; use std::{ io, @@ -95,6 +96,14 @@ impl LineEnding { pub struct HomeDir(pub PathBuf); +impl Deref for HomeDir { + type Target = PathBuf; + + fn deref(&self) -> &Self::Target { + &self.0 + } +} + #[async_trait::async_trait] pub trait Fs: Send + Sync { async fn create_dir(&self, path: &Path) -> Result<()>; diff --git a/crates/project/src/project.rs b/crates/project/src/project.rs index f964726c4c..f05b7e6728 100644 --- a/crates/project/src/project.rs +++ b/crates/project/src/project.rs @@ -583,7 +583,10 @@ impl Project { cx: &mut gpui::TestAppContext, ) -> ModelHandle { if !cx.read(|cx| cx.has_global::()) { - cx.update(|cx| cx.set_global(Settings::test(cx))); + cx.update(|cx| { + cx.set_global(Settings::test(cx)); + cx.set_global(HomeDir(Path::new("/tmp/").to_path_buf())) + }); } let languages = Arc::new(LanguageRegistry::test()); diff --git a/crates/project/src/worktree.rs b/crates/project/src/worktree.rs index 333511ee46..c58fcd4638 100644 --- a/crates/project/src/worktree.rs +++ b/crates/project/src/worktree.rs @@ -1840,23 +1840,27 @@ impl language::File for File { fn full_path(&self, cx: &AppContext) -> PathBuf { let mut full_path = PathBuf::new(); let worktree = self.worktree.read(cx); + if worktree.is_visible() { full_path.push(worktree.root_name()); } else { if let Some(path) = worktree.as_local().map(|local| local.abs_path.clone()) { - if let Ok(trimmed_path) = path.strip_prefix(cx.global::().0.as_path()) { + if let Ok(trimmed_path) = path.strip_prefix(cx.global::().as_path()) { full_path.push("~"); full_path.push(trimmed_path); } else { full_path.push(path) } } else { - full_path.push(Path::new("/host-filesystem/")) + full_path.push(Path::new("/OUTSIDE_PROJECT")); + full_path.push(worktree.root_name()); } } + if self.path.components().next().is_some() { full_path.push(&self.path); } + full_path } diff --git a/crates/terminal/src/terminal_view.rs b/crates/terminal/src/terminal_view.rs index 732c0a717e..5ca5eb6dce 100644 --- a/crates/terminal/src/terminal_view.rs +++ b/crates/terminal/src/terminal_view.rs @@ -38,18 +38,7 @@ pub struct SendKeystroke(String); actions!( terminal, - [ - Up, - Down, - CtrlC, - Escape, - Enter, - Clear, - Copy, - Paste, - ShowCharacterPalette, - SearchTest - ] + [Clear, Copy, Paste, ShowCharacterPalette, SearchTest] ); impl_actions!(terminal, [SendText, SendKeystroke]);