Skip to content

Commit 8eb4e84

Browse files
author
Benjamin Pasero
committed
quick access - first cut open anything
1 parent b7bfce3 commit 8eb4e84

12 files changed

Lines changed: 592 additions & 51 deletions

File tree

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import { localize } from 'vs/nls';
77
import { IQuickPickSeparator } from 'vs/platform/quickinput/common/quickInput';
8-
import { PickerQuickAccessProvider, IPickerQuickAccessItem } from 'vs/platform/quickinput/browser/pickerQuickAccess';
8+
import { PickerQuickAccessProvider, IPickerQuickAccessItem, IPickerQuickAccessProviderOptions } from 'vs/platform/quickinput/browser/pickerQuickAccess';
99
import { distinct } from 'vs/base/common/arrays';
1010
import { CancellationToken } from 'vs/base/common/cancellation';
1111
import { DisposableStore, Disposable, IDisposable } from 'vs/base/common/lifecycle';
@@ -30,7 +30,7 @@ export interface ICommandQuickPick extends IPickerQuickAccessItem {
3030
commandAlias: string | undefined;
3131
}
3232

33-
export interface ICommandsQuickAccessOptions {
33+
export interface ICommandsQuickAccessOptions extends IPickerQuickAccessProviderOptions {
3434
showAlias: boolean;
3535
}
3636

@@ -43,14 +43,14 @@ export abstract class AbstractCommandsQuickAccessProvider extends PickerQuickAcc
4343
private readonly commandsHistory = this._register(this.instantiationService.createInstance(CommandsHistory));
4444

4545
constructor(
46-
private options: ICommandsQuickAccessOptions,
46+
protected options: ICommandsQuickAccessOptions,
4747
@IInstantiationService private readonly instantiationService: IInstantiationService,
4848
@IKeybindingService private readonly keybindingService: IKeybindingService,
4949
@ICommandService private readonly commandService: ICommandService,
5050
@ITelemetryService private readonly telemetryService: ITelemetryService,
5151
@INotificationService private readonly notificationService: INotificationService
5252
) {
53-
super(AbstractCommandsQuickAccessProvider.PREFIX);
53+
super(AbstractCommandsQuickAccessProvider.PREFIX, options);
5454
}
5555

5656
protected async getPicks(filter: string, disposables: DisposableStore, token: CancellationToken): Promise<Array<ICommandQuickPick | IQuickPickSeparator>> {

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

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,21 @@ export interface IPickerQuickAccessItem extends IQuickPickItem {
5353
trigger?(buttonIndex: number, keyMods: IKeyMods): TriggerAction | Promise<TriggerAction>;
5454
}
5555

56+
export interface IPickerQuickAccessProviderOptions {
57+
canAcceptInBackground?: boolean;
58+
}
59+
5660
export abstract class PickerQuickAccessProvider<T extends IPickerQuickAccessItem> extends Disposable implements IQuickAccessProvider {
5761

58-
constructor(private prefix: string) {
62+
constructor(private prefix: string, protected options?: IPickerQuickAccessProviderOptions) {
5963
super();
6064
}
6165

6266
provide(picker: IQuickPick<T>, token: CancellationToken): IDisposable {
6367
const disposables = new DisposableStore();
6468

65-
// Allow subclasses to configure picker
66-
this.configure(picker);
69+
// Apply options if any
70+
picker.canAcceptInBackground = !!this.options?.canAcceptInBackground;
6771

6872
// Disable filtering & sorting, we control the results
6973
picker.matchOnLabel = picker.matchOnDescription = picker.matchOnDetail = picker.sortByLabel = false;
@@ -142,13 +146,6 @@ export abstract class PickerQuickAccessProvider<T extends IPickerQuickAccessItem
142146
return disposables;
143147
}
144148

145-
/**
146-
* Subclasses can override this method to configure the picker before showing it.
147-
*
148-
* @param picker the picker instance used for the quick access before it opens.
149-
*/
150-
protected configure(picker: IQuickPick<T>): void { }
151-
152149
/**
153150
* Returns an array of picks and separators as needed. If the picks are resolved
154151
* long running, the provided cancellation token should be used to cancel the

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import { localize } from 'vs/nls';
7-
import { IQuickPickSeparator, quickPickItemScorerAccessor, IQuickPickItemWithResource, IQuickPick } from 'vs/platform/quickinput/common/quickInput';
7+
import { IQuickPickSeparator, quickPickItemScorerAccessor, IQuickPickItemWithResource } from 'vs/platform/quickinput/common/quickInput';
88
import { PickerQuickAccessProvider, IPickerQuickAccessItem, TriggerAction } from 'vs/platform/quickinput/browser/pickerQuickAccess';
99
import { IEditorGroupsService, GroupsOrder } from 'vs/workbench/services/editor/common/editorGroupsService';
1010
import { EditorsOrder, IEditorIdentifier, toResource, SideBySideEditor } from 'vs/workbench/common/editor';
@@ -25,13 +25,7 @@ export abstract class BaseEditorQuickAccessProvider extends PickerQuickAccessPro
2525
@IModelService private readonly modelService: IModelService,
2626
@IModeService private readonly modeService: IModeService
2727
) {
28-
super(prefix);
29-
}
30-
31-
protected configure(picker: IQuickPick<IEditorQuickPickItem>): void {
32-
33-
// Allow to open editors in background without closing picker
34-
picker.canAcceptInBackground = true;
28+
super(prefix, { canAcceptInBackground: true });
3529
}
3630

3731
protected getPicks(filter: string): Array<IEditorQuickPickItem | IQuickPickSeparator> {

0 commit comments

Comments
 (0)