mirror of
https://github.com/Microsoft/vscode
synced 2024-09-13 21:55:38 +00:00
debt - smarter initial commands picker
This commit is contained in:
parent
beabfb15c8
commit
30afe8898a
|
@ -31,6 +31,7 @@ import { INotificationService } from 'vs/platform/notification/common/notificati
|
|||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { timeout } from 'vs/base/common/async';
|
||||
|
||||
export const ALL_COMMANDS_PREFIX = '>';
|
||||
|
||||
|
@ -376,6 +377,7 @@ export class CommandsHandler extends QuickOpenHandler {
|
|||
|
||||
private commandHistoryEnabled: boolean;
|
||||
private commandsHistory: CommandsHistory;
|
||||
private extensionsRegistered: boolean;
|
||||
|
||||
constructor(
|
||||
@IEditorService private readonly editorService: IEditorService,
|
||||
|
@ -389,6 +391,8 @@ export class CommandsHandler extends QuickOpenHandler {
|
|||
|
||||
this.commandsHistory = this.instantiationService.createInstance(CommandsHistory);
|
||||
|
||||
this.extensionService.whenInstalledExtensionsRegistered().then(() => this.extensionsRegistered = true);
|
||||
|
||||
this.configurationService.onDidChangeConfiguration(e => this.updateConfiguration());
|
||||
this.updateConfiguration();
|
||||
}
|
||||
|
@ -398,12 +402,20 @@ export class CommandsHandler extends QuickOpenHandler {
|
|||
}
|
||||
|
||||
getResults(searchValue: string, token: CancellationToken): Promise<QuickOpenModel> {
|
||||
if (this.extensionsRegistered) {
|
||||
return this.doGetResults(searchValue, token);
|
||||
}
|
||||
|
||||
// wait for extensions being registered to cover all commands
|
||||
// also from extensions
|
||||
return this.extensionService.whenInstalledExtensionsRegistered().then(() => {
|
||||
// If extensions are not yet registered, we wait for a little moment to give them
|
||||
// a chance to register so that the complete set of commands shows up as result
|
||||
// We do not want to delay functionality beyond that time though to keep the commands
|
||||
// functional.
|
||||
return Promise.race([timeout(800), this.extensionService.whenInstalledExtensionsRegistered().then(() => undefined)]).then(() => this.doGetResults(searchValue, token));
|
||||
}
|
||||
|
||||
private doGetResults(searchValue: string, token: CancellationToken): Promise<QuickOpenModel> {
|
||||
if (token.isCancellationRequested) {
|
||||
return new QuickOpenModel([]);
|
||||
return Promise.resolve(new QuickOpenModel([]));
|
||||
}
|
||||
|
||||
searchValue = searchValue.trim();
|
||||
|
@ -479,8 +491,7 @@ export class CommandsHandler extends QuickOpenHandler {
|
|||
}
|
||||
}
|
||||
|
||||
return new QuickOpenModel(entries);
|
||||
});
|
||||
return Promise.resolve(new QuickOpenModel(entries));
|
||||
}
|
||||
|
||||
private editorActionsToEntries(actions: IEditorAction[], searchValue: string): EditorActionCommandEntry[] {
|
||||
|
|
Loading…
Reference in a new issue