From 36ff31858bfc08410d7e82e23b889627331f60cb Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Tue, 8 Feb 2022 20:09:53 +0100 Subject: [PATCH] Set file in `test_diagnostics` to excercise language server --- crates/language/src/buffer.rs | 8 +++----- crates/language/src/tests.rs | 5 ++++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/crates/language/src/buffer.rs b/crates/language/src/buffer.rs index eb49e3ca95..c4823836b7 100644 --- a/crates/language/src/buffer.rs +++ b/crates/language/src/buffer.rs @@ -247,12 +247,12 @@ pub trait LocalFile: File { ); } -#[cfg(feature = "test-support")] +#[cfg(any(test, feature = "test-support"))] pub struct FakeFile { pub path: Arc, } -#[cfg(feature = "test-support")] +#[cfg(any(test, feature = "test-support"))] impl File for FakeFile { fn as_local(&self) -> Option<&dyn LocalFile> { Some(self) @@ -333,7 +333,7 @@ impl File for FakeFile { } } -#[cfg(feature = "test-support")] +#[cfg(any(test, feature = "test-support"))] impl LocalFile for FakeFile { fn abs_path(&self, _: &AppContext) -> PathBuf { self.path.to_path_buf() @@ -759,8 +759,6 @@ impl Buffer { } else { None }; - - self.update_language_server(cx); } pub fn did_save( diff --git a/crates/language/src/tests.rs b/crates/language/src/tests.rs index 0e436b495b..25f58cdb42 100644 --- a/crates/language/src/tests.rs +++ b/crates/language/src/tests.rs @@ -570,8 +570,11 @@ async fn test_diagnostics(mut cx: gpui::TestAppContext) { " .unindent(); + let file = Box::new(FakeFile { + path: Path::new("/some/path").into(), + }) as Box; let buffer = cx.add_model(|cx| { - Buffer::new(0, text, cx) + Buffer::from_file(0, text, file, cx) .with_language(Arc::new(rust_lang), cx) .with_language_server(language_server, cx) });