|
5 | 5 |
|
6 | 6 | import * as os from 'os';
|
7 | 7 | import * as path from 'path';
|
8 |
| -import { Command, commands, Disposable, LineChange, MessageOptions, Position, ProgressLocation, QuickPickItem, Range, SourceControlResourceState, TextDocumentShowOptions, TextEditor, Uri, ViewColumn, window, workspace, WorkspaceEdit, WorkspaceFolder, TimelineItem, env, Selection, TextDocumentContentProvider, InputBoxValidationSeverity, TabInputText, TabInputTextMerge, QuickPickItemKind, TextDocument, LogOutputChannel, l10n, Memento, UIKind, QuickInputButton, ThemeIcon, SourceControlHistoryItem, SourceControl, InputBoxValidationMessage } from 'vscode'; |
| 8 | +import { Command, commands, Disposable, LineChange, MessageOptions, Position, ProgressLocation, QuickPickItem, Range, SourceControlResourceState, TextDocumentShowOptions, TextEditor, Uri, ViewColumn, window, workspace, WorkspaceEdit, WorkspaceFolder, TimelineItem, env, Selection, TextDocumentContentProvider, InputBoxValidationSeverity, TabInputText, TabInputTextMerge, QuickPickItemKind, TextDocument, LogOutputChannel, l10n, Memento, UIKind, QuickInputButton, ThemeIcon, SourceControlHistoryItem, SourceControl, InputBoxValidationMessage, Tab, TabInputNotebook } from 'vscode'; |
9 | 9 | import TelemetryReporter from '@vscode/extension-telemetry';
|
10 | 10 | import { uniqueNamesGenerator, adjectives, animals, colors, NumberDictionary } from '@joaomoreno/unique-names-generator';
|
11 | 11 | import { ForcePushMode, GitErrorCodes, Ref, RefType, Status, CommitOptions, RemoteSourcePublisher, Remote } from './api/git';
|
@@ -3994,6 +3994,37 @@ export class CommandCenter {
|
3994 | 3994 | repository.closeDiffEditors(undefined, undefined, true);
|
3995 | 3995 | }
|
3996 | 3996 |
|
| 3997 | + @command('git.closeAllUnmodifiedEditors') |
| 3998 | + closeUnmodifiedEditors(): void { |
| 3999 | + const editorTabsToClose: Tab[] = []; |
| 4000 | + |
| 4001 | + // Collect all modified files |
| 4002 | + const modifiedFiles: string[] = []; |
| 4003 | + for (const repository of this.model.repositories) { |
| 4004 | + modifiedFiles.push(...repository.indexGroup.resourceStates.map(r => r.resourceUri.fsPath)); |
| 4005 | + modifiedFiles.push(...repository.workingTreeGroup.resourceStates.map(r => r.resourceUri.fsPath)); |
| 4006 | + modifiedFiles.push(...repository.untrackedGroup.resourceStates.map(r => r.resourceUri.fsPath)); |
| 4007 | + modifiedFiles.push(...repository.mergeGroup.resourceStates.map(r => r.resourceUri.fsPath)); |
| 4008 | + } |
| 4009 | + |
| 4010 | + // Collect all editor tabs that are not dirty and not modified |
| 4011 | + for (const tab of window.tabGroups.all.map(g => g.tabs).flat()) { |
| 4012 | + if (tab.isDirty) { |
| 4013 | + continue; |
| 4014 | + } |
| 4015 | + |
| 4016 | + if (tab.input instanceof TabInputText || tab.input instanceof TabInputNotebook) { |
| 4017 | + const { uri } = tab.input; |
| 4018 | + if (!modifiedFiles.find(p => pathEquals(p, uri.fsPath))) { |
| 4019 | + editorTabsToClose.push(tab); |
| 4020 | + } |
| 4021 | + } |
| 4022 | + } |
| 4023 | + |
| 4024 | + // Close editors |
| 4025 | + window.tabGroups.close(editorTabsToClose, true); |
| 4026 | + } |
| 4027 | + |
3997 | 4028 | @command('git.openRepositoriesInParentFolders')
|
3998 | 4029 | async openRepositoriesInParentFolders(): Promise<void> {
|
3999 | 4030 | const parentRepositories: string[] = [];
|
|
0 commit comments