Skip to content

Change markFileAsViewed to keep files open by default #7319

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
},
Expand Down
31 changes: 18 additions & 13 deletions src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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<boolean>(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);
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/common/settingKeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
export const CODING_AGENT_AUTO_COMMIT_AND_PUSH = 'autoCommitAndPush';
export const CLOSE_ON_MARK_FILE_AS_VIEWED = 'closeFileOnMarkFileAsViewed';