Uses current branch when opening remote file

Adds current branch name to quick pick description
This commit is contained in:
Eric Amodio
2017-03-24 13:32:32 -04:00
parent e906bfcb9e
commit e859f697ec
7 changed files with 60 additions and 45 deletions

View File

@@ -1,7 +1,7 @@
'use strict';
import { TextEditor, Uri, window } from 'vscode';
import { ActiveEditorCommand, Commands } from './commands';
import { GitRemote, RemoteProviderOpenType } from '../gitService';
import { GitRemote, RemoteOpenType } from '../gitService';
import { Logger } from '../logger';
import { CommandQuickPickItem, OpenRemoteCommandQuickPickItem, RemotesQuickPick } from '../quickPicks';
@@ -11,7 +11,7 @@ export class OpenInRemoteCommand extends ActiveEditorCommand {
super(Commands.OpenInRemote);
}
async execute(editor: TextEditor, uri?: Uri, remotes?: GitRemote[], type?: RemoteProviderOpenType, args?: string[], name?: string, goBackCommand?: CommandQuickPickItem) {
async execute(editor: TextEditor, uri?: Uri, remotes?: GitRemote[], type?: RemoteOpenType, args?: string[], goBackCommand?: CommandQuickPickItem) {
if (!(uri instanceof Uri)) {
uri = editor && editor.document && editor.document.uri;
}
@@ -20,7 +20,7 @@ export class OpenInRemoteCommand extends ActiveEditorCommand {
if (!remotes) return undefined;
if (remotes.length === 1) {
const command = new OpenRemoteCommandQuickPickItem(remotes[0], type, ...args, name);
const command = new OpenRemoteCommandQuickPickItem(remotes[0], type, ...args);
return command.execute();
}
@@ -34,14 +34,15 @@ export class OpenInRemoteCommand extends ActiveEditorCommand {
placeHolder = `open commit ${shortSha} in\u2026`;
break;
case 'file':
const shortFileSha = (args[1] && args[1].substring(0, 8)) || '';
case 'working-file':
const shortFileSha = (args[2] && args[2].substring(0, 8)) || '';
const shaSuffix = shortFileSha ? ` \u00a0\u2022\u00a0 ${shortFileSha}` : '';
placeHolder = `open ${args[0]}${shaSuffix} in\u2026`;
break;
}
const pick = await RemotesQuickPick.show(remotes, placeHolder, type, args, name, goBackCommand);
const pick = await RemotesQuickPick.show(remotes, placeHolder, type, args, goBackCommand);
return pick && pick.execute();
}