Adds line support to Open File in Remote command

This commit is contained in:
Eric Amodio
2017-03-28 02:12:15 -04:00
parent a724244914
commit 8a0e27b7df
5 changed files with 56 additions and 22 deletions

View File

@@ -1,6 +1,6 @@
'use strict';
import { Arrays } from '../system';
import { commands, TextEditor, TextEditorEdit, Uri, window } from 'vscode';
import { commands, Range, TextEditor, TextEditorEdit, Uri, window } from 'vscode';
import { ActiveEditorCommand, Commands } from './commands';
import { GitService, GitUri } from '../gitService';
import { Logger } from '../logger';
@@ -22,7 +22,8 @@ export class OpenFileInRemoteCommand extends ActiveEditorCommand {
try {
const remotes = Arrays.uniqueBy(await this.git.getRemotes(this.repoPath), _ => _.url, _ => !!_.provider);
return commands.executeCommand(Commands.OpenInRemote, uri, remotes, 'file', [gitUri.getRelativePath(), branch.name, gitUri.sha]);
const range = editor && new Range(editor.selection.start.with({ line: editor.selection.start.line + 1 }), editor.selection.end.with({ line: editor.selection.end.line + 1 }));
return commands.executeCommand(Commands.OpenInRemote, uri, remotes, 'file', [gitUri.getRelativePath(), branch.name, gitUri.sha, range]);
}
catch (ex) {
Logger.error(ex, 'OpenFileInRemoteCommand');