Close git diff tabs with same path when new one is opened

This commit is contained in:
Jeremy Soller 2025-11-06 19:49:36 -07:00
parent fbad8439ae
commit 0a3b248c67
No known key found for this signature in database
GPG key ID: 670FDFB5428E05CA

View file

@ -2149,6 +2149,21 @@ impl Application for App {
}
}
Message::OpenGitDiff(project_path, diff) => {
// Close any diff tabs with same path
{
let mut close = Vec::new();
for entity in self.tab_model.iter() {
if let Some(Tab::GitDiff(other_tab)) = self.tab_model.data::<Tab>(entity) {
if other_tab.diff.path == diff.path {
close.push(entity);
}
}
}
for entity in close {
self.tab_model.remove(entity);
}
}
let relative_path = match diff.path.strip_prefix(project_path.clone()) {
Ok(ok) => ok,
Err(err) => {