Browse Source

Opens changes and files in the active column

main
Eric Amodio 6 years ago
parent
commit
2ef4051c3d
2 changed files with 15 additions and 10 deletions
  1. +2
    -2
      src/commands/common.ts
  2. +13
    -8
      src/commands/diffWith.ts

+ 2
- 2
src/commands/common.ts View File

@ -1,5 +1,5 @@
'use strict';
import { commands, Disposable, SourceControlResourceGroup, SourceControlResourceState, TextDocumentShowOptions, TextEditor, TextEditorEdit, Uri, window, workspace } from 'vscode';
import { commands, Disposable, SourceControlResourceGroup, SourceControlResourceState, TextDocumentShowOptions, TextEditor, TextEditorEdit, Uri, ViewColumn, window, workspace } from 'vscode';
import { ExplorerNode, ExplorerRefNode } from '../views/explorerNodes';
import { GitBranch, GitCommit, GitRemote, GitUri } from '../gitService';
import { Logger } from '../logger';
@ -305,7 +305,7 @@ export async function openEditor(uri: Uri, options: TextDocumentShowOptions & {
return window.showTextDocument(document, {
preserveFocus: false,
preview: true,
viewColumn: (window.activeTextEditor && window.activeTextEditor.viewColumn) || 1,
viewColumn: ViewColumn.Active,
...opts
});
}

+ 13
- 8
src/commands/diffWith.ts View File

@ -1,5 +1,5 @@
'use strict';
import { commands, Range, TextDocumentShowOptions, TextEditor, Uri, window } from 'vscode';
import { commands, Range, TextDocumentShowOptions, TextEditor, Uri, ViewColumn, window } from 'vscode';
import { ActiveEditorCommand, Commands } from './common';
import { BuiltInCommands, GlyphChars } from '../constants';
import { Container } from '../container';
@ -103,13 +103,6 @@ export class DiffWithCommand extends ActiveEditorCommand {
Container.git.getVersionedFile(args.repoPath, args.rhs.uri.fsPath, args.rhs.sha)
]);
if (args.line !== undefined && args.line !== 0) {
if (args.showOptions === undefined) {
args.showOptions = {};
}
args.showOptions.selection = new Range(args.line, 0, args.line, 0);
}
let rhsPrefix = '';
if (rhs === undefined) {
rhsPrefix = GitService.isUncommitted(args.rhs.sha)
@ -144,6 +137,18 @@ export class DiffWithCommand extends ActiveEditorCommand {
? `${args.lhs.title} ${GlyphChars.ArrowLeftRight} ${args.rhs.title}`
: args.lhs.title || args.rhs.title;
if (args.showOptions === undefined) {
args.showOptions = {};
}
if (args.showOptions.viewColumn === undefined) {
args.showOptions.viewColumn = ViewColumn.Active;
}
if (args.line !== undefined && args.line !== 0) {
args.showOptions.selection = new Range(args.line, 0, args.line, 0);
}
return await commands.executeCommand(BuiltInCommands.Diff,
lhs === undefined
? GitUri.toRevisionUri(GitService.deletedSha, args.lhs.uri.fsPath, args.repoPath)

Loading…
Cancel
Save