Close git diff tabs with same path when new one is opened
This commit is contained in:
parent
fbad8439ae
commit
0a3b248c67
1 changed files with 15 additions and 0 deletions
15
src/main.rs
15
src/main.rs
|
|
@ -2149,6 +2149,21 @@ impl Application for App {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Message::OpenGitDiff(project_path, diff) => {
|
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()) {
|
let relative_path = match diff.path.strip_prefix(project_path.clone()) {
|
||||||
Ok(ok) => ok,
|
Ok(ok) => ok,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue