diff --git a/src/commandsAndMenu.tsx b/src/commandsAndMenu.tsx index bddbc9986..f55da4088 100644 --- a/src/commandsAndMenu.tsx +++ b/src/commandsAndMenu.tsx @@ -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;