Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Don't prompt to save unchanged files

Conrad Irwin3573896fe02c
diff --git a/crates/vim/src/command.rs b/crates/vim/src/command.rs
index 092d72c2fcd..6c78de18440 100644
--- a/crates/vim/src/command.rs
+++ b/crates/vim/src/command.rs
@@ -430,5 +430,9 @@ mod test {
cx.workspace(|workspace, cx| assert_eq!(workspace.items(cx).count(), 2));
cx.simulate_keystrokes([":", "q", "enter"]);
cx.workspace(|workspace, cx| assert_eq!(workspace.items(cx).count(), 1));
+ cx.simulate_keystrokes([":", "n", "e", "w", "enter"]);
+ cx.workspace(|workspace, cx| assert_eq!(workspace.items(cx).count(), 2));
+ cx.simulate_keystrokes([":", "q", "a", "enter"]);
+ cx.workspace(|workspace, cx| assert_eq!(workspace.items(cx).count(), 0));
}
}
diff --git a/crates/workspace/src/pane.rs b/crates/workspace/src/pane.rs
index 0f717a0edfb..576a4e313b4 100644
--- a/crates/workspace/src/pane.rs
+++ b/crates/workspace/src/pane.rs
@@ -893,9 +893,13 @@ impl Pane {
) -> Task<Result<()>> {
// Find the items to close.
let mut items_to_close = Vec::new();
+ let mut dirty_items = Vec::new();
for item in &self.items {
if should_close(item.id()) {
items_to_close.push(item.boxed_clone());
+ if item.is_dirty(cx) {
+ dirty_items.push(item.boxed_clone());
+ }
}
}
@@ -907,13 +911,10 @@ impl Pane {
let workspace = self.workspace.clone();
cx.spawn(|pane, mut cx| async move {
- if save_intent == SaveIntent::Close && items_to_close.len() > 1 {
+ if save_intent == SaveIntent::Close && dirty_items.len() > 1 {
let mut answer = pane.update(&mut cx, |_, cx| {
- let prompt = Self::file_names_for_prompt(
- &mut items_to_close.iter(),
- items_to_close.len(),
- cx,
- );
+ let prompt =
+ Self::file_names_for_prompt(&mut dirty_items.iter(), dirty_items.len(), cx);
cx.prompt(
PromptLevel::Warning,
&prompt,
@@ -921,7 +922,7 @@ impl Pane {
)
})?;
match answer.next().await {
- Some(0) => save_intent = SaveIntent::Save,
+ Some(0) => save_intent = SaveIntent::SaveAll,
Some(1) => save_intent = SaveIntent::Skip,
_ => {}
}
diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs
index 2f82ed3701a..beb35d16548 100644
--- a/crates/workspace/src/workspace.rs
+++ b/crates/workspace/src/workspace.rs
@@ -1419,7 +1419,7 @@ impl Workspace {
)
})?;
match answer.next().await {
- Some(0) => save_intent = SaveIntent::Save,
+ Some(0) => save_intent = SaveIntent::SaveAll,
Some(1) => save_intent = SaveIntent::Skip,
_ => {}
}