Fix project search unsaved edits (#30864)
Closes #30820 Release Notes: - Fixed an issue where entering a new search in the project search would drop unsaved edits in the project search buffer --------- Co-authored-by: Mark Janssen <20283+praseodym@users.noreply.github.com>
This commit is contained in:
parent
4d827924f0
commit
f56960ab5b
3 changed files with 151 additions and 54 deletions
|
@ -564,6 +564,10 @@ pub trait ItemHandle: 'static + Send {
|
|||
fn preserve_preview(&self, cx: &App) -> bool;
|
||||
fn include_in_nav_history(&self) -> bool;
|
||||
fn relay_action(&self, action: Box<dyn Action>, window: &mut Window, cx: &mut App);
|
||||
fn can_autosave(&self, cx: &App) -> bool {
|
||||
let is_deleted = self.project_entry_ids(cx).is_empty();
|
||||
self.is_dirty(cx) && !self.has_conflict(cx) && self.can_save(cx) && !is_deleted
|
||||
}
|
||||
}
|
||||
|
||||
pub trait WeakItemHandle: Send + Sync {
|
||||
|
|
|
@ -1857,7 +1857,7 @@ impl Pane {
|
|||
matches!(
|
||||
item.workspace_settings(cx).autosave,
|
||||
AutosaveSetting::OnFocusChange | AutosaveSetting::OnWindowChange
|
||||
) && Self::can_autosave_item(item, cx)
|
||||
) && item.can_autosave(cx)
|
||||
})?;
|
||||
if !will_autosave {
|
||||
let item_id = item.item_id();
|
||||
|
@ -1945,11 +1945,6 @@ impl Pane {
|
|||
})
|
||||
}
|
||||
|
||||
fn can_autosave_item(item: &dyn ItemHandle, cx: &App) -> bool {
|
||||
let is_deleted = item.project_entry_ids(cx).is_empty();
|
||||
item.is_dirty(cx) && !item.has_conflict(cx) && item.can_save(cx) && !is_deleted
|
||||
}
|
||||
|
||||
pub fn autosave_item(
|
||||
item: &dyn ItemHandle,
|
||||
project: Entity<Project>,
|
||||
|
@ -1960,7 +1955,7 @@ impl Pane {
|
|||
item.workspace_settings(cx).autosave,
|
||||
AutosaveSetting::AfterDelay { .. }
|
||||
);
|
||||
if Self::can_autosave_item(item, cx) {
|
||||
if item.can_autosave(cx) {
|
||||
item.save(format, project, window, cx)
|
||||
} else {
|
||||
Task::ready(Ok(()))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue