mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-01-24 17:24:53 -05:00
Refactors commit quick pick commands
Splits showQuickCommitDetails into showQuickCommitDetails and showQuickCommitFileDetails Adds closeUnchangedFiles command Adds openChangedFiles command Adds diffDirectory command Adds contextual description to the `go back` commands Fixes #44 by adding a warning message about Git version requirements Fixes intermittent errors when adding active line annotations Fixes intermittent errors when opening multiple files via quick picks Updates dependencies Preps v2.11.0
This commit is contained in:
41
src/commands/openChangedFiles.ts
Normal file
41
src/commands/openChangedFiles.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
'use strict';
|
||||
import { TextEditor, Uri, window } from 'vscode';
|
||||
import { ActiveEditorCommand, Commands, openEditor } from './commands';
|
||||
import { GitProvider } from '../gitProvider';
|
||||
import { Logger } from '../logger';
|
||||
import * as path from 'path';
|
||||
|
||||
export class OpenChangedFilesCommand extends ActiveEditorCommand {
|
||||
|
||||
constructor(private git: GitProvider, public repoPath: string) {
|
||||
super(Commands.OpenChangedFiles);
|
||||
}
|
||||
|
||||
async execute(editor: TextEditor, uri?: Uri, uris?: Uri[]) {
|
||||
if (!(uri instanceof Uri)) {
|
||||
uri = editor && editor.document && editor.document.uri;
|
||||
}
|
||||
|
||||
try {
|
||||
if (!uris) {
|
||||
const repoPath = await this.git.getRepoPathFromUri(uri, this.repoPath);
|
||||
if (!repoPath) return window.showWarningMessage(`Unable to open changed files`);
|
||||
|
||||
const statuses = await this.git.getStatusesForRepo(repoPath);
|
||||
if (!statuses) return window.showWarningMessage(`Unable to open changed files`);
|
||||
|
||||
uris = statuses.filter(_ => _.status !== 'D').map(_ => Uri.file(path.resolve(repoPath, _.fileName)));
|
||||
}
|
||||
|
||||
for (const uri of uris) {
|
||||
await openEditor(uri, true);
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
catch (ex) {
|
||||
Logger.error('[GitLens.OpenChangedFilesCommand]', ex);
|
||||
return window.showErrorMessage(`Unable to open changed files. See output channel for more details`);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user