Reworks more commands deal with context

This commit is contained in:
Eric Amodio
2017-06-27 01:19:39 -04:00
parent 9179b70875
commit 1751987868
5 changed files with 220 additions and 144 deletions

View File

@@ -1,6 +1,6 @@
'use strict';
import { TextDocumentShowOptions, TextEditor, Uri, window } from 'vscode';
import { ActiveEditorCommand, Commands, getCommandUri, openEditor } from './common';
import { ActiveEditorCommand, CommandContext, Commands, getCommandUri, openEditor } from './common';
import { GitService } from '../gitService';
import { Logger } from '../logger';
import { Messages } from '../messages';
@@ -15,7 +15,23 @@ export class OpenChangedFilesCommand extends ActiveEditorCommand {
super(Commands.OpenChangedFiles);
}
async execute(editor: TextEditor, uri?: Uri, args: OpenChangedFilesCommandArgs = {}) {
async run(context: CommandContext, args: OpenChangedFilesCommandArgs = {}): Promise<any> {
// Since we can change the args and they could be cached -- make a copy
switch (context.type) {
case 'uri':
return this.execute(context.editor, context.uri, { ...args });
case 'scm-states':
return undefined;
case 'scm-groups':
// const group = context.scmResourceGroups[0];
// args.uris = group.resourceStates.map(_ => _.resourceUri);
return this.execute(undefined, undefined, { ...args });
default:
return this.execute(context.editor, undefined, { ...args });
}
}
async execute(editor: TextEditor | undefined, uri?: Uri, args: OpenChangedFilesCommandArgs = {}) {
uri = getCommandUri(uri, editor);
try {