mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-12 13:24:19 +00:00
Select the language in Editor::save_as instead of Buffer::did_save
Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
This commit is contained in:
parent
fcf6a9d58a
commit
90cc01a50a
2 changed files with 6 additions and 4 deletions
|
@ -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);
|
||||
});
|
||||
})
|
||||
|
|
|
@ -710,6 +710,11 @@ impl Buffer {
|
|||
&self.visible_text
|
||||
}
|
||||
|
||||
pub fn set_language(&mut self, language: Option<Arc<Language>>, cx: &mut ModelContext<Self>) {
|
||||
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);
|
||||
|
|
Loading…
Reference in a new issue