From 5b85f38106c1b5ecc8179ff863cd565a5ac22949 Mon Sep 17 00:00:00 2001 From: Lahari Gandrapu Date: Thu, 9 Oct 2025 21:58:51 -0400 Subject: [PATCH] feat: add keybinding support for markFileAsViewed --- package.json | 7 +++++++ src/commands.ts | 28 +++++++++++++++------------- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index 90109cb7a3..30add35817 100644 --- a/package.json +++ b/package.json @@ -1983,6 +1983,13 @@ "mac": "cmd+k m", "command": "pr.makeSuggestion", "when": "commentEditorFocused" + }, + { + "key": "ctrl+shift+v", + "mac": "cmd+shift+v", + "command": "pr.markFileAsViewed", + "args": { "dontCloseFile": true }, + "when": "resourcePath in github:unviewedFiles" } ], "menus": { diff --git a/src/commands.ts b/src/commands.ts index 56c5efb5f8..b633f8bdbf 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -1505,7 +1505,7 @@ ${contents} }; context.subscriptions.push( - vscode.commands.registerCommand('pr.markFileAsViewed', async (treeNode: FileChangeNode | vscode.Uri | undefined) => { + vscode.commands.registerCommand('pr.markFileAsViewed', async (treeNode: FileChangeNode | vscode.Uri | undefined, options?: { dontCloseFile?: boolean }) => { try { if (treeNode === undefined) { // Use the active editor to enable keybindings @@ -1515,18 +1515,20 @@ ${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); + // Only close the file when dontCloseFile is not true + if (!options?.dontCloseFile) { + // 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); + } } }