Skip to content

Commit 2d06062

Browse files
committed
Stops showing compare view on Select for Compare
Fixes focus issues with compare picker
1 parent 0f5c4ab commit 2d06062

File tree

3 files changed

+25
-12
lines changed

3 files changed

+25
-12
lines changed

src/views/compareView.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,13 @@ export class CompareView extends ViewBase<CompareNode> {
149149

150150
private async addResults(results: ViewNode) {
151151
if (!this.visible) {
152-
void (await this.show());
152+
await this.show();
153153
}
154154

155155
const root = this.ensureRoot();
156156
root.addOrReplace(results, !this.keepResults);
157157

158-
setImmediate(() => this.reveal(results, { select: true, expand: true }));
158+
setImmediate(() => this.reveal(results, { expand: true, focus: true, select: true }));
159159
}
160160

161161
private setFilesLayout(layout: ViewFilesLayout) {

src/views/nodes/compareNode.ts

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { TreeItem, TreeItemCollapsibleState } from 'vscode';
33
import { getRepoPathOrPrompt } from '../../commands';
44
import { CommandContext, GlyphChars, NamedRef, setCommandContext } from '../../constants';
55
import { GitService } from '../../git/gitService';
6-
import { CommandQuickPickItem, ReferencesQuickPick } from '../../quickpicks';
6+
import { ReferencesQuickPick } from '../../quickpicks';
77
import { debug, gate, Iterables, log, Promises } from '../../system';
88
import { CompareView } from '../compareView';
99
import { MessageNode } from './common';
@@ -135,6 +135,7 @@ export class CompareNode extends ViewNode<CompareView> {
135135
else if (repoPath !== this._selectedRef.repoPath) {
136136
// If we don't have a matching repoPath, then start over
137137
void this.selectForCompare(repoPath, ref);
138+
138139
return;
139140
}
140141

@@ -148,7 +149,12 @@ export class CompareNode extends ViewNode<CompareView> {
148149
checkmarks: true
149150
}
150151
);
151-
if (pick === undefined || pick instanceof CommandQuickPickItem) return;
152+
if (pick === undefined) {
153+
await this.view.show();
154+
await this.view.reveal(this._comparePickerNode!, { focus: true, select: true });
155+
156+
return;
157+
}
152158

153159
ref = pick.ref;
154160
}
@@ -165,15 +171,25 @@ export class CompareNode extends ViewNode<CompareView> {
165171
if (repoPath === undefined) {
166172
repoPath = await getRepoPathOrPrompt(`Compare in which repository${GlyphChars.Ellipsis}`);
167173
}
168-
if (repoPath === undefined) return;
174+
if (repoPath === undefined) {
175+
await this.view.show();
176+
await this.view.reveal(this._comparePickerNode!, { focus: true, select: true });
177+
178+
return;
179+
}
169180

170181
let autoCompare = false;
171182
if (ref === undefined) {
172183
const pick = await new ReferencesQuickPick(repoPath).show(`Compare${GlyphChars.Ellipsis}`, {
173184
allowEnteringRefs: true,
174185
checkmarks: false
175186
});
176-
if (pick === undefined || pick instanceof CommandQuickPickItem) return;
187+
if (pick === undefined) {
188+
await this.view.show();
189+
await this.view.reveal(this._comparePickerNode!, { focus: true, select: true });
190+
191+
return;
192+
}
177193

178194
ref = pick.ref;
179195

@@ -183,9 +199,8 @@ export class CompareNode extends ViewNode<CompareView> {
183199
this._selectedRef = { label: this.getRefName(ref), repoPath: repoPath, ref: ref };
184200
setCommandContext(CommandContext.ViewsCanCompare, true);
185201

186-
await this.view.show();
187-
188202
void (await this.triggerChange());
203+
await this.view.reveal(this._comparePickerNode!, { focus: true, select: true });
189204

190205
if (autoCompare) {
191206
void (await this.compareWithSelected());

src/views/viewBase.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ export abstract class ViewBase<TRoot extends ViewNode<View>> implements TreeData
201201
const location = this.location;
202202

203203
try {
204-
return await commands.executeCommand(`${this.id}${location ? `:${location}` : ''}.focus`);
204+
void (await commands.executeCommand(`${this.id}${location ? `:${location}` : ''}.focus`));
205205
}
206206
catch (ex) {
207207
Logger.error(ex);
@@ -218,11 +218,9 @@ export abstract class ViewBase<TRoot extends ViewNode<View>> implements TreeData
218218
if (result === actions[0]) {
219219
await configuration.update(setting, true, ConfigurationTarget.Global);
220220

221-
return commands.executeCommand(`${this.id}${location ? `:${location}` : ''}.focus`);
221+
void (await commands.executeCommand(`${this.id}${location ? `:${location}` : ''}.focus`));
222222
}
223223
}
224-
225-
return undefined;
226224
}
227225
}
228226

0 commit comments

Comments
 (0)