|
6 | 6 | import * as fs from 'fs';
|
7 | 7 | import * as path from 'path';
|
8 | 8 | import * as picomatch from 'picomatch';
|
9 |
| -import { CancellationToken, Command, Disposable, Event, EventEmitter, Memento, ProgressLocation, ProgressOptions, scm, SourceControl, SourceControlInputBox, SourceControlInputBoxValidation, SourceControlInputBoxValidationType, SourceControlResourceDecorations, SourceControlResourceGroup, SourceControlResourceState, ThemeColor, Uri, window, workspace, WorkspaceEdit, FileDecoration, commands, Tab, TabInputTextDiff, TabInputNotebookDiff, RelativePattern, CancellationTokenSource, LogOutputChannel, LogLevel, CancellationError, l10n } from 'vscode'; |
| 9 | +import { CancellationToken, Command, Disposable, Event, EventEmitter, Memento, ProgressLocation, ProgressOptions, scm, SourceControl, SourceControlInputBox, SourceControlInputBoxValidation, SourceControlInputBoxValidationType, SourceControlResourceDecorations, SourceControlResourceGroup, SourceControlResourceState, ThemeColor, Uri, window, workspace, WorkspaceEdit, FileDecoration, commands, TabInputTextDiff, TabInputNotebookDiff, TabInputTextMultiDiff, RelativePattern, CancellationTokenSource, LogOutputChannel, LogLevel, CancellationError, l10n } from 'vscode'; |
10 | 10 | import TelemetryReporter from '@vscode/extension-telemetry';
|
11 | 11 | import { Branch, Change, ForcePushMode, GitErrorCodes, LogOptions, Ref, Remote, Status, CommitOptions, BranchQuery, FetchOptions, RefQuery, RefType } from './api/git';
|
12 | 12 | import { AutoFetcher } from './autofetch';
|
@@ -1358,22 +1358,29 @@ export class Repository implements Disposable {
|
1358 | 1358 | const config = workspace.getConfiguration('git', Uri.file(this.root));
|
1359 | 1359 | if (!config.get<boolean>('closeDiffOnOperation', false) && !ignoreSetting) { return; }
|
1360 | 1360 |
|
1361 |
| - const diffEditorTabsToClose: Tab[] = []; |
1362 |
| - |
1363 |
| - for (const tab of window.tabGroups.all.map(g => g.tabs).flat()) { |
1364 |
| - const { input } = tab; |
1365 |
| - if (input instanceof TabInputTextDiff || input instanceof TabInputNotebookDiff) { |
1366 |
| - if (input.modified.scheme === 'git' && (indexResources === undefined || indexResources.some(r => pathEquals(r, input.modified.fsPath)))) { |
1367 |
| - // Index |
1368 |
| - diffEditorTabsToClose.push(tab); |
1369 |
| - } |
1370 |
| - if (input.modified.scheme === 'file' && input.original.scheme === 'git' && (workingTreeResources === undefined || workingTreeResources.some(r => pathEquals(r, input.modified.fsPath)))) { |
1371 |
| - // Working Tree |
1372 |
| - diffEditorTabsToClose.push(tab); |
1373 |
| - } |
| 1361 | + function checkTabShouldClose(input: TabInputTextDiff | TabInputNotebookDiff) { |
| 1362 | + if (input.modified.scheme === 'git' && (indexResources === undefined || indexResources.some(r => pathEquals(r, input.modified.fsPath)))) { |
| 1363 | + // Index |
| 1364 | + return true; |
| 1365 | + } |
| 1366 | + if (input.modified.scheme === 'file' && input.original.scheme === 'git' && (workingTreeResources === undefined || workingTreeResources.some(r => pathEquals(r, input.modified.fsPath)))) { |
| 1367 | + // Working Tree |
| 1368 | + return true; |
1374 | 1369 | }
|
| 1370 | + return false; |
1375 | 1371 | }
|
1376 | 1372 |
|
| 1373 | + const diffEditorTabsToClose = window.tabGroups.all |
| 1374 | + .flatMap(g => g.tabs) |
| 1375 | + .filter(({ input }) => { |
| 1376 | + if (input instanceof TabInputTextDiff || input instanceof TabInputNotebookDiff) { |
| 1377 | + return checkTabShouldClose(input); |
| 1378 | + } else if (input instanceof TabInputTextMultiDiff) { |
| 1379 | + return input.textDiffs.every(checkTabShouldClose); |
| 1380 | + } |
| 1381 | + return false; |
| 1382 | + }); |
| 1383 | + |
1377 | 1384 | // Close editors
|
1378 | 1385 | window.tabGroups.close(diffEditorTabsToClose, true);
|
1379 | 1386 | }
|
|
0 commit comments