Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
28 changes: 15 additions & 13 deletions src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
}
}
}

Expand Down