Skip to content

Commit 96783c3

Browse files
refactor: use command args instead of setting for markFileAsViewed behavior
1 parent aa4ff18 commit 96783c3

File tree

3 files changed

+10
-14
lines changed

3 files changed

+10
-14
lines changed

package.json

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -735,11 +735,6 @@
735735
"type": "boolean",
736736
"default": false,
737737
"description": "%githubIssues.alwaysPromptForNewIssueRepo.description%"
738-
},
739-
"githubPullRequests.closeFileOnMarkFileAsViewed": {
740-
"type": "boolean",
741-
"description": "Close the diff editor automatically when marking a file as viewed from the editor title menu or via shortcut.",
742-
"default": true
743738
}
744739
}
745740
},
@@ -2855,7 +2850,10 @@
28552850
{
28562851
"command": "pr.markFileAsViewed",
28572852
"group": "navigation",
2858-
"when": "resourceScheme != pr && resourceScheme != review && resourceScheme != filechange && resourcePath in github:unviewedFiles"
2853+
"when": "resourceScheme != pr && resourceScheme != review && resourceScheme != filechange && resourcePath in github:unviewedFiles",
2854+
"args": {
2855+
"closeFile": true
2856+
}
28592857
},
28602858
{
28612859
"command": "pr.unmarkFileAsViewed",

src/commands.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { CommentReply, findActiveHandler, resolveCommentHandler } from './commen
1212
import { COPILOT_LOGINS } from './common/copilot';
1313
import { commands } from './common/executeCommands';
1414
import Logger from './common/logger';
15-
import { CLOSE_ON_MARK_FILE_AS_VIEWED, FILE_LIST_LAYOUT, PR_SETTINGS_NAMESPACE } from './common/settingKeys';
15+
import { FILE_LIST_LAYOUT, PR_SETTINGS_NAMESPACE } from './common/settingKeys';
1616
import { editQuery } from './common/settingsUtils';
1717
import { ITelemetry } from './common/telemetry';
1818
import { asTempStorageURI, fromPRUri, fromReviewUri, Schemes, toPRUri } from './common/uri';
@@ -1356,7 +1356,7 @@ ${contents}
13561356
};
13571357

13581358
context.subscriptions.push(
1359-
vscode.commands.registerCommand('pr.markFileAsViewed', async (treeNode: FileChangeNode | vscode.Uri | undefined) => {
1359+
vscode.commands.registerCommand('pr.markFileAsViewed', async (treeNode: FileChangeNode | vscode.Uri | undefined, args?: { closeFile?: boolean }) => {
13601360
try {
13611361
if (treeNode === undefined) {
13621362
// Use the active editor to enable keybindings
@@ -1366,10 +1366,9 @@ ${contents}
13661366
if (treeNode instanceof FileChangeNode) {
13671367
await treeNode.markFileAsViewed(false);
13681368
} else if (treeNode) {
1369-
// When the argument is a uri it came from the editor menu. By default we close the editor
1370-
// after marking the file as viewed, but this can be controlled by a setting.
1371-
const shouldCloseEditor = vscode.workspace.getConfiguration(PR_SETTINGS_NAMESPACE)
1372-
.get<boolean>(CLOSE_ON_MARK_FILE_AS_VIEWED, true);
1369+
// When the argument is a uri it came from the editor menu. By default we don't close the editor
1370+
// but this can be controlled by the command argument
1371+
const shouldCloseEditor = args?.closeFile ?? false;
13731372
if (shouldCloseEditor) {
13741373
// Do the close first to improve perceived performance of marking as viewed.
13751374
const tab = vscode.window.tabGroups.activeTabGroup.activeTab;

src/common/settingKeys.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,5 +89,4 @@ export const COLOR_THEME = 'colorTheme';
8989

9090
export const CODING_AGENT = `${PR_SETTINGS_NAMESPACE}.codingAgent`;
9191
export const CODING_AGENT_ENABLED = 'enabled';
92-
export const CODING_AGENT_AUTO_COMMIT_AND_PUSH = 'autoCommitAndPush';
93-
export const CLOSE_ON_MARK_FILE_AS_VIEWED = 'closeFileOnMarkFileAsViewed';
92+
export const CODING_AGENT_AUTO_COMMIT_AND_PUSH = 'autoCommitAndPush';

0 commit comments

Comments
 (0)