Skip to content

Commit aa4ff18

Browse files
feat: do not close file
1 parent ec09627 commit aa4ff18

File tree

4 files changed

+32
-14
lines changed

4 files changed

+32
-14
lines changed

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,11 @@
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
738743
}
739744
}
740745
},

src/@types/vscode.proposed.chatParticipantAdditions.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,13 @@ declare module 'vscode' {
258258
readonly tools: Map<string, boolean>;
259259
}
260260

261+
export namespace lm {
262+
/**
263+
* Fired when the set of tools on a chat request changes.
264+
*/
265+
export const onDidChangeChatRequestTools: Event<ChatRequest>;
266+
}
267+
261268
// TODO@API fit this into the stream
262269
export interface ChatUsedContext {
263270
documents: ChatDocumentContext[];

src/commands.ts

Lines changed: 18 additions & 13 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 { FILE_LIST_LAYOUT, PR_SETTINGS_NAMESPACE } from './common/settingKeys';
15+
import { CLOSE_ON_MARK_FILE_AS_VIEWED, 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';
@@ -1366,18 +1366,23 @@ ${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 and we should also close the file
1370-
// Do the close first to improve perceived performance of marking as viewed.
1371-
const tab = vscode.window.tabGroups.activeTabGroup.activeTab;
1372-
if (tab) {
1373-
let compareUri: vscode.Uri | undefined = undefined;
1374-
if (tab.input instanceof vscode.TabInputTextDiff) {
1375-
compareUri = tab.input.modified;
1376-
} else if (tab.input instanceof vscode.TabInputText) {
1377-
compareUri = tab.input.uri;
1378-
}
1379-
if (compareUri && treeNode.toString() === compareUri.toString()) {
1380-
vscode.window.tabGroups.close(tab);
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);
1373+
if (shouldCloseEditor) {
1374+
// Do the close first to improve perceived performance of marking as viewed.
1375+
const tab = vscode.window.tabGroups.activeTabGroup.activeTab;
1376+
if (tab) {
1377+
let compareUri: vscode.Uri | undefined = undefined;
1378+
if (tab.input instanceof vscode.TabInputTextDiff) {
1379+
compareUri = tab.input.modified;
1380+
} else if (tab.input instanceof vscode.TabInputText) {
1381+
compareUri = tab.input.uri;
1382+
}
1383+
if (compareUri && treeNode.toString() === compareUri.toString()) {
1384+
vscode.window.tabGroups.close(tab);
1385+
}
13811386
}
13821387
}
13831388

src/common/settingKeys.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,5 @@ 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';
92+
export const CODING_AGENT_AUTO_COMMIT_AND_PUSH = 'autoCommitAndPush';
93+
export const CLOSE_ON_MARK_FILE_AS_VIEWED = 'closeFileOnMarkFileAsViewed';

0 commit comments

Comments
 (0)