diff --git a/package.json b/package.json index 893b0193bf..a29db59dd8 100644 --- a/package.json +++ b/package.json @@ -748,6 +748,11 @@ "type": "boolean", "default": false, "description": "%githubIssues.alwaysPromptForNewIssueRepo.description%" + }, + "githubPullRequests.closeFileOnMarkFileAsViewed": { + "type": "boolean", + "description": "Close the diff editor automatically when marking a file as viewed from the editor title menu or via shortcut.", + "default": true } } }, diff --git a/src/commands.ts b/src/commands.ts index c3662762af..67f81ec262 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -12,7 +12,7 @@ import { CommentReply, findActiveHandler, resolveCommentHandler } from './commen import { COPILOT_LOGINS } from './common/copilot'; import { commands } from './common/executeCommands'; import Logger from './common/logger'; -import { FILE_LIST_LAYOUT, PR_SETTINGS_NAMESPACE } from './common/settingKeys'; +import { CLOSE_ON_MARK_FILE_AS_VIEWED, FILE_LIST_LAYOUT, PR_SETTINGS_NAMESPACE } from './common/settingKeys'; import { editQuery } from './common/settingsUtils'; import { ITelemetry } from './common/telemetry'; import { asTempStorageURI, fromPRUri, fromReviewUri, Schemes, toPRUri } from './common/uri'; @@ -1441,18 +1441,23 @@ ${contents} if (treeNode instanceof FileChangeNode) { await treeNode.markFileAsViewed(false); } else if (treeNode) { - // When the argument is a uri it came from the editor menu and we should also close the file - // Do the close first to improve perceived performance of marking as viewed. - const tab = vscode.window.tabGroups.activeTabGroup.activeTab; - if (tab) { - let compareUri: vscode.Uri | undefined = undefined; - if (tab.input instanceof vscode.TabInputTextDiff) { - compareUri = tab.input.modified; - } else if (tab.input instanceof vscode.TabInputText) { - compareUri = tab.input.uri; - } - if (compareUri && treeNode.toString() === compareUri.toString()) { - vscode.window.tabGroups.close(tab); + // When the argument is a uri it came from the editor menu. By default we close the editor + // after marking the file as viewed, but this can be controlled by a setting. + const shouldCloseEditor = vscode.workspace.getConfiguration(PR_SETTINGS_NAMESPACE) + .get(CLOSE_ON_MARK_FILE_AS_VIEWED, true); + if (shouldCloseEditor) { + // Do the close first to improve perceived performance of marking as viewed. + const tab = vscode.window.tabGroups.activeTabGroup.activeTab; + if (tab) { + let compareUri: vscode.Uri | undefined = undefined; + if (tab.input instanceof vscode.TabInputTextDiff) { + compareUri = tab.input.modified; + } else if (tab.input instanceof vscode.TabInputText) { + compareUri = tab.input.uri; + } + if (compareUri && treeNode.toString() === compareUri.toString()) { + vscode.window.tabGroups.close(tab); + } } } diff --git a/src/common/settingKeys.ts b/src/common/settingKeys.ts index 9db3eeee8d..db5979a126 100644 --- a/src/common/settingKeys.ts +++ b/src/common/settingKeys.ts @@ -89,4 +89,5 @@ export const COLOR_THEME = 'colorTheme'; export const CODING_AGENT = `${PR_SETTINGS_NAMESPACE}.codingAgent`; export const CODING_AGENT_ENABLED = 'enabled'; -export const CODING_AGENT_AUTO_COMMIT_AND_PUSH = 'autoCommitAndPush'; \ No newline at end of file +export const CODING_AGENT_AUTO_COMMIT_AND_PUSH = 'autoCommitAndPush'; +export const CLOSE_ON_MARK_FILE_AS_VIEWED = 'closeFileOnMarkFileAsViewed'; \ No newline at end of file