Fix item closing overly triggering save dialogues (#21374)
Closes https://github.com/zed-industries/zed/issues/12029 Allows to introspect project items inside items more deeply, checking them for being dirty. For that: * renames `project::Item` into `project::ProjectItem` * adds an `is_dirty(&self) -> bool` method to the renamed trait * changes the closing logic to only care about dirty project items when checking for save prompts conditions * save prompts are raised only if the item is singleton without a project path; or if the item has dirty project items that are not open elsewhere Release Notes: - Fixed item closing overly triggering save dialogues
This commit is contained in:
parent
c2cd84a749
commit
28849dd2a8
19 changed files with 600 additions and 85 deletions
|
@ -1,6 +1,6 @@
|
|||
use crate::{
|
||||
worktree_store::{WorktreeStore, WorktreeStoreEvent},
|
||||
Project, ProjectEntryId, ProjectPath,
|
||||
Project, ProjectEntryId, ProjectItem, ProjectPath,
|
||||
};
|
||||
use anyhow::{Context as _, Result};
|
||||
use collections::{hash_map, HashMap, HashSet};
|
||||
|
@ -114,7 +114,7 @@ impl ImageItem {
|
|||
}
|
||||
}
|
||||
|
||||
impl crate::Item for ImageItem {
|
||||
impl ProjectItem for ImageItem {
|
||||
fn try_open(
|
||||
project: &Model<Project>,
|
||||
path: &ProjectPath,
|
||||
|
@ -151,6 +151,10 @@ impl crate::Item for ImageItem {
|
|||
fn project_path(&self, cx: &AppContext) -> Option<ProjectPath> {
|
||||
Some(self.project_path(cx).clone())
|
||||
}
|
||||
|
||||
fn is_dirty(&self) -> bool {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
trait ImageStoreImpl {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue