diff --git a/src/views/compareView.ts b/src/views/compareView.ts index 6316e2c..4c1e5f9 100644 --- a/src/views/compareView.ts +++ b/src/views/compareView.ts @@ -149,13 +149,13 @@ export class CompareView extends ViewBase { private async addResults(results: ViewNode) { if (!this.visible) { - void (await this.show()); + await this.show(); } const root = this.ensureRoot(); root.addOrReplace(results, !this.keepResults); - setImmediate(() => this.reveal(results, { select: true, expand: true })); + setImmediate(() => this.reveal(results, { expand: true, focus: true, select: true })); } private setFilesLayout(layout: ViewFilesLayout) { diff --git a/src/views/nodes/compareNode.ts b/src/views/nodes/compareNode.ts index a6bdf8b..b07f327 100644 --- a/src/views/nodes/compareNode.ts +++ b/src/views/nodes/compareNode.ts @@ -3,7 +3,7 @@ import { TreeItem, TreeItemCollapsibleState } from 'vscode'; import { getRepoPathOrPrompt } from '../../commands'; import { CommandContext, GlyphChars, NamedRef, setCommandContext } from '../../constants'; import { GitService } from '../../git/gitService'; -import { CommandQuickPickItem, ReferencesQuickPick } from '../../quickpicks'; +import { ReferencesQuickPick } from '../../quickpicks'; import { debug, gate, Iterables, log, Promises } from '../../system'; import { CompareView } from '../compareView'; import { MessageNode } from './common'; @@ -135,6 +135,7 @@ export class CompareNode extends ViewNode { else if (repoPath !== this._selectedRef.repoPath) { // If we don't have a matching repoPath, then start over void this.selectForCompare(repoPath, ref); + return; } @@ -148,7 +149,12 @@ export class CompareNode extends ViewNode { checkmarks: true } ); - if (pick === undefined || pick instanceof CommandQuickPickItem) return; + if (pick === undefined) { + await this.view.show(); + await this.view.reveal(this._comparePickerNode!, { focus: true, select: true }); + + return; + } ref = pick.ref; } @@ -165,7 +171,12 @@ export class CompareNode extends ViewNode { if (repoPath === undefined) { repoPath = await getRepoPathOrPrompt(`Compare in which repository${GlyphChars.Ellipsis}`); } - if (repoPath === undefined) return; + if (repoPath === undefined) { + await this.view.show(); + await this.view.reveal(this._comparePickerNode!, { focus: true, select: true }); + + return; + } let autoCompare = false; if (ref === undefined) { @@ -173,7 +184,12 @@ export class CompareNode extends ViewNode { allowEnteringRefs: true, checkmarks: false }); - if (pick === undefined || pick instanceof CommandQuickPickItem) return; + if (pick === undefined) { + await this.view.show(); + await this.view.reveal(this._comparePickerNode!, { focus: true, select: true }); + + return; + } ref = pick.ref; @@ -183,9 +199,8 @@ export class CompareNode extends ViewNode { this._selectedRef = { label: this.getRefName(ref), repoPath: repoPath, ref: ref }; setCommandContext(CommandContext.ViewsCanCompare, true); - await this.view.show(); - void (await this.triggerChange()); + await this.view.reveal(this._comparePickerNode!, { focus: true, select: true }); if (autoCompare) { void (await this.compareWithSelected()); diff --git a/src/views/viewBase.ts b/src/views/viewBase.ts index 3b639e4..3db72a1 100644 --- a/src/views/viewBase.ts +++ b/src/views/viewBase.ts @@ -201,7 +201,7 @@ export abstract class ViewBase> implements TreeData const location = this.location; try { - return await commands.executeCommand(`${this.id}${location ? `:${location}` : ''}.focus`); + void (await commands.executeCommand(`${this.id}${location ? `:${location}` : ''}.focus`)); } catch (ex) { Logger.error(ex); @@ -218,11 +218,9 @@ export abstract class ViewBase> implements TreeData if (result === actions[0]) { await configuration.update(setting, true, ConfigurationTarget.Global); - return commands.executeCommand(`${this.id}${location ? `:${location}` : ''}.focus`); + void (await commands.executeCommand(`${this.id}${location ? `:${location}` : ''}.focus`)); } } - - return undefined; } }