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:
Kirill Bulatov 2024-12-01 01:48:31 +02:00 committed by GitHub
parent c2cd84a749
commit 28849dd2a8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 600 additions and 85 deletions

View file

@ -7511,7 +7511,7 @@ mod tests {
path: ProjectPath,
}
impl project::Item for TestProjectItem {
impl project::ProjectItem for TestProjectItem {
fn try_open(
_project: &Model<Project>,
path: &ProjectPath,
@ -7528,6 +7528,10 @@ mod tests {
fn project_path(&self, _: &AppContext) -> Option<ProjectPath> {
Some(self.path.clone())
}
fn is_dirty(&self) -> bool {
false
}
}
impl ProjectItem for TestProjectItemView {