Move the save and save_as code paths close together
This commit is contained in:
parent
de6eb00e2b
commit
3a7cfc3901
7 changed files with 125 additions and 169 deletions
|
@ -608,20 +608,11 @@ impl Item for Editor {
|
|||
cx: &mut ViewContext<Self>,
|
||||
) -> Task<Result<()>> {
|
||||
self.report_event("save editor", cx);
|
||||
|
||||
let buffer = self.buffer().clone();
|
||||
let buffers = buffer.read(cx).all_buffers();
|
||||
let save = project.update(cx, |project, cx| project.save_buffers(buffers, cx));
|
||||
let format = self.perform_format(project.clone(), cx);
|
||||
let buffers = self.buffer().clone().read(cx).all_buffers();
|
||||
cx.spawn(|_, mut cx| async move {
|
||||
let (format_transaction, save) = save.await;
|
||||
buffer.update(&mut cx, |buffer, _| {
|
||||
if let Some(transaction) = format_transaction {
|
||||
if !buffer.is_singleton() {
|
||||
buffer.push_transaction(&transaction.0);
|
||||
}
|
||||
}
|
||||
});
|
||||
save.await?;
|
||||
format.await?;
|
||||
cx.update(|cx| Project::save_buffers(buffers, cx)).await?;
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
|
@ -1144,7 +1135,6 @@ fn path_for_file<'a>(
|
|||
mod tests {
|
||||
use super::*;
|
||||
use gpui::MutableAppContext;
|
||||
use language::RopeFingerprint;
|
||||
use std::{
|
||||
path::{Path, PathBuf},
|
||||
sync::Arc,
|
||||
|
@ -1190,17 +1180,6 @@ mod tests {
|
|||
todo!()
|
||||
}
|
||||
|
||||
fn save(
|
||||
&self,
|
||||
_: u64,
|
||||
_: language::Rope,
|
||||
_: clock::Global,
|
||||
_: project::LineEnding,
|
||||
_: &mut MutableAppContext,
|
||||
) -> gpui::Task<anyhow::Result<(clock::Global, RopeFingerprint, SystemTime)>> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn as_any(&self) -> &dyn std::any::Any {
|
||||
todo!()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue