Skip to content

Commit cb1c7be

Browse files
author
Benjamin Pasero
committed
quick access - align more with current solution
1 parent 7d4cd4a commit cb1c7be

16 files changed

Lines changed: 78 additions & 58 deletions

File tree

src/vs/base/browser/ui/selectBox/selectBoxCustom.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ export class SelectBoxList extends Disposable implements ISelectBoxDelegate, ILi
354354
content.push(`.monaco-select-box-dropdown-container > .select-box-dropdown-list-container .monaco-list .monaco-list-row.option-disabled:hover { background-color: ${this.styles.selectBackground} !important; }`);
355355
}
356356

357-
// Match quickOpen outline styles - ignore for disabled options
357+
// Match quick input outline styles - ignore for disabled options
358358
if (this.styles.listFocusOutline) {
359359
content.push(`.monaco-select-box-dropdown-container > .select-box-dropdown-list-container .monaco-list .monaco-list-row.focused { outline: 1.6px dotted ${this.styles.listFocusOutline} !important; outline-offset: -1.6px !important; }`);
360360
}

src/vs/base/parts/quickinput/browser/quickInput.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,7 @@ class QuickPick<T extends IQuickPickItem> extends QuickInput implements IQuickPi
391391
private _matchOnLabel = true;
392392
private _sortByLabel = true;
393393
private _autoFocusOnList = true;
394+
private _autoFocusSecondEntry = false;
394395
private _activeItems: T[] = [];
395396
private activeItemsUpdated = false;
396397
private activeItemsToConfirm: T[] | null = [];
@@ -520,7 +521,6 @@ class QuickPick<T extends IQuickPickItem> extends QuickInput implements IQuickPi
520521
this.update();
521522
}
522523

523-
524524
get autoFocusOnList() {
525525
return this._autoFocusOnList;
526526
}
@@ -530,6 +530,14 @@ class QuickPick<T extends IQuickPickItem> extends QuickInput implements IQuickPi
530530
this.update();
531531
}
532532

533+
get autoFocusSecondEntry() {
534+
return this._autoFocusSecondEntry;
535+
}
536+
537+
set autoFocusSecondEntry(autoFocusSecondEntry: boolean) {
538+
this._autoFocusSecondEntry = autoFocusSecondEntry;
539+
}
540+
533541
get activeItems() {
534542
return this._activeItems;
535543
}
@@ -851,10 +859,9 @@ class QuickPick<T extends IQuickPickItem> extends QuickInput implements IQuickPi
851859
this.ui.checkAll.checked = this.ui.list.getAllVisibleChecked();
852860
this.ui.visibleCount.setCount(this.ui.list.getVisibleCount());
853861
this.ui.count.setCount(this.ui.list.getCheckedCount());
854-
if (isQuickNavigating && previousItemCount === 0) {
855-
// quick navigate: automatically focus the second entry
856-
// so that upon release the item is picked directly
862+
if (this._autoFocusSecondEntry && previousItemCount === 0) {
857863
this.ui.list.focus(QuickInputListFocus.Second);
864+
this._autoFocusSecondEntry = false;
858865
} else {
859866
this.trySelectFirst();
860867
}

src/vs/base/parts/quickinput/common/quickInput.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,14 @@ export interface IQuickPick<T extends IQuickPickItem> extends IQuickInput {
237237

238238
autoFocusOnList: boolean;
239239

240+
/**
241+
* If enabled, will try to select the second entry of the picks
242+
* once they appear instead of the first one. This is useful
243+
* e.g. when `quickNavigate` is enabled to be able to select
244+
* a previous entry by just releasing the quick nav keys.
245+
*/
246+
autoFocusSecondEntry: boolean;
247+
240248
quickNavigate: IQuickNavigateConfiguration | undefined;
241249

242250
activeItems: ReadonlyArray<T>;

src/vs/platform/quickinput/browser/commandsQuickAccess.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ interface ICommandsQuickAccessConfiguration {
178178
};
179179
}
180180

181-
class CommandsHistory extends Disposable {
181+
export class CommandsHistory extends Disposable {
182182

183183
static readonly DEFAULT_COMMANDS_HISTORY_LENGTH = 50;
184184

src/vs/platform/quickinput/browser/quickAccess.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export class QuickAccessController extends Disposable implements IQuickAccessCon
4040
picker.placeholder = descriptor?.placeholder;
4141
picker.value = value;
4242
picker.quickNavigate = options?.quickNavigateConfiguration;
43+
picker.autoFocusSecondEntry = !!options?.quickNavigateConfiguration || !!options?.autoFocus?.autoFocusSecondEntry;
4344
picker.valueSelection = options?.inputSelection ? [options.inputSelection.start, options.inputSelection.end] : [value.length, value.length];
4445
picker.contextKey = descriptor?.contextKey;
4546
picker.filterValue = (value: string) => value.substring(descriptor ? descriptor.prefix.length : 0);

src/vs/platform/quickinput/common/quickAccess.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ export interface IQuickAccessOptions {
2121
* Allows to enable quick navigate support in quick input.
2222
*/
2323
quickNavigateConfiguration?: IQuickNavigateConfiguration;
24+
25+
/**
26+
* Wether to select the second pick item by default instead of the first.
27+
*/
28+
autoFocus?: { autoFocusSecondEntry?: boolean }
2429
}
2530

2631
export interface IQuickAccessController {

src/vs/workbench/browser/parts/editor/noTabsTitleControl.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ export class NoTabsTitleControl extends TitleControl {
110110
}
111111
}
112112
} else {
113-
// @rebornix
113+
// TODO@rebornix
114114
// gesture tap should open the quick open
115115
// editorGroupView will focus on the editor again when there are mouse/pointer/touch down events
116116
// we need to wait a bit as `GesureEvent.Tap` is generated from `touchstart` and then `touchend` evnets, which are not an atom event.

src/vs/workbench/browser/quickopen.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -330,14 +330,9 @@ export class QuickOpenAction extends Action {
330330
super(id, label);
331331

332332
this.prefix = prefix;
333-
this.enabled = !!this.quickOpenService;
334333
}
335334

336-
run(): Promise<void> {
337-
338-
// Show with prefix
335+
async run(): Promise<void> {
339336
this.quickOpenService.show(this.prefix);
340-
341-
return Promise.resolve(undefined);
342337
}
343338
}

src/vs/workbench/contrib/codeEditor/browser/quickaccess/gotoSymbolQuickAccess.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export class GotoSymbolQuickAccessProvider extends AbstractGotoSymbolQuickAccess
6161
Registry.as<IQuickAccessRegistry>(Extensions.Quickaccess).registerQuickAccessProvider({
6262
ctor: GotoSymbolQuickAccessProvider,
6363
prefix: AbstractGotoSymbolQuickAccessProvider.PREFIX,
64+
contextKey: 'inFileSymbolsPicker',
6465
placeholder: localize('gotoSymbolQuickAccessPlaceholder', "Type the name of a symbol to go to."),
6566
helpEntries: [
6667
{ description: localize('gotoSymbolQuickAccess', "Go to Symbol in Editor"), prefix: AbstractGotoSymbolQuickAccessProvider.PREFIX, needsEditor: true },

src/vs/workbench/contrib/debug/browser/debug.contribution.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ registerDebugCommandPaletteItem(TOGGLE_INLINE_BREAKPOINT_ID, nls.localize('inlin
180180
Registry.as<IQuickAccessRegistry>(QuickAccessExtensions.Quickaccess).registerQuickAccessProvider({
181181
ctor: StartDebugQuickAccessProvider,
182182
prefix: StartDebugQuickAccessProvider.PREFIX,
183+
contextKey: 'inLaunchConfigurationsPicker',
183184
placeholder: nls.localize('startDebugPlaceholder', "Type the name of a launch configuration to run."),
184185
helpEntries: [{ description: nls.localize('startDebugHelp', "Start Debug Configurations"), needsEditor: false }]
185186
});

0 commit comments

Comments
 (0)