Skip to content

Commit

Permalink
Close diff only for file in index or working state (#1140)
Browse files Browse the repository at this point in the history
Fixes #1137
  • Loading branch information
fcollonval authored Jul 7, 2022
1 parent 20bc055 commit 0a50d7e
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions src/commandsAndMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -607,14 +607,23 @@ export function addCommands(
modelIsLoading.reject(msg);
}

gitModel.statusChanged.connect((_, status) => {
const targetFile = status.files.find(
fileStatus => model.filename === fileStatus.from
);
if (!targetFile || targetFile.status === 'unmodified') {
mainAreaItem.dispose();
}
});
if (
model.challenger.source === Git.Diff.SpecialRef.INDEX ||
model.challenger.source === Git.Diff.SpecialRef.WORKING ||
model.reference.source === Git.Diff.SpecialRef.INDEX ||
model.reference.source === Git.Diff.SpecialRef.WORKING
) {
const maybeClose = (_: IGitExtension, status: Git.IStatus) => {
const targetFile = status.files.find(
fileStatus => model.filename === fileStatus.from
);
if (!targetFile || targetFile.status === 'unmodified') {
gitModel.statusChanged.disconnect(maybeClose);
mainAreaItem.dispose();
}
};
gitModel.statusChanged.connect(maybeClose);
}
}

return mainAreaItem;
Expand Down

0 comments on commit 0a50d7e

Please sign in to comment.