diff --git a/extensions/git/src/commands.ts b/extensions/git/src/commands.ts index 7cd713101f97fe66a0b247f6bf64c6b3932db5ad..08b020afd35456aff4995931db91c3ef86135713 100644 --- a/extensions/git/src/commands.ts +++ b/extensions/git/src/commands.ts @@ -152,10 +152,10 @@ export class CommandCenter { @command('git.openResource') async openResource(resource: Resource): Promise { - await this._openResource(resource, undefined, true); + await this._openResource(resource, undefined, true, false); } - private async _openResource(resource: Resource, preview?: boolean, preserveFocus?: boolean): Promise { + private async _openResource(resource: Resource, preview?: boolean, preserveFocus?: boolean, preserveSelection?: boolean): Promise { const left = this.getLeftResource(resource); const right = this.getRightResource(resource); const title = this.getTitle(resource); @@ -174,7 +174,7 @@ export class CommandCenter { const activeTextEditor = window.activeTextEditor; - if (activeTextEditor && activeTextEditor.document.uri.fsPath === right.fsPath) { + if (preserveSelection && activeTextEditor && activeTextEditor.document.uri.fsPath === right.fsPath) { opts.selection = activeTextEditor.selection; } @@ -406,6 +406,7 @@ export class CommandCenter { @command('git.openChange') async openChange(arg?: Resource | Uri, ...resourceStates: SourceControlResourceState[]): Promise { const preserveFocus = arg instanceof Resource; + const preserveSelection = arg instanceof Uri || !arg; let resources: Resource[] | undefined = undefined; if (arg instanceof Uri) { @@ -433,7 +434,7 @@ export class CommandCenter { const preview = resources.length === 1 ? undefined : false; for (const resource of resources) { - await this._openResource(resource, preview, preserveFocus); + await this._openResource(resource, preview, preserveFocus, preserveSelection); } }