diff --git a/zed/src/editor.rs b/zed/src/editor.rs index 4fea4be1de..ac63f0c80d 100644 --- a/zed/src/editor.rs +++ b/zed/src/editor.rs @@ -2671,6 +2671,7 @@ impl workspace::ItemView for Editor { cx.spawn(|buffer, mut cx| async move { save_as.await.map(|new_file| { buffer.update(&mut cx, |buffer, cx| { + buffer.set_language(new_file.select_language(cx), cx); buffer.did_save(version, new_file.mtime, Some(new_file), cx); }); }) diff --git a/zed/src/editor/buffer.rs b/zed/src/editor/buffer.rs index fd6cd0c4d0..7f3fdd3653 100644 --- a/zed/src/editor/buffer.rs +++ b/zed/src/editor/buffer.rs @@ -710,6 +710,11 @@ impl Buffer { &self.visible_text } + pub fn set_language(&mut self, language: Option>, cx: &mut ModelContext) { + self.language = language; + self.reparse(cx); + } + pub fn did_save( &mut self, version: time::Global, @@ -720,10 +725,6 @@ impl Buffer { self.saved_mtime = mtime; self.saved_version = version; if let Some(new_file) = new_file { - if let Some(language) = new_file.select_language(cx) { - self.language = Some(language); - self.reparse(cx); - } self.file = Some(new_file); } cx.emit(Event::Saved);