Skip to content

Commit

Permalink
monaco-quick-input-service: set context key "inQuickOpen"
Browse files Browse the repository at this point in the history
Context Key "inQuickOpen" exists in vscode and its value (true or false) reflects
whether the Quick Open, AKA Quick input, is currently open/visible or not.

This context key can be useful in Theia too, e.g. it can be used in the "when"
clause of commands registered by vscode extensions, or programmatically whenever
it's useful to know the state of the Quick Open UI.

Signed-off-by: Marc Dumais <marc.dumais@ericsson.com>
Co-authored-by: FernandoAscencio <fernando.ascencio.cama@ericsson.com>
  • Loading branch information
FernandoAscencio committed Apr 14, 2023
1 parent 6c7f3b1 commit d21ae06
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/monaco/src/browser/monaco-quick-input-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { MonacoResolvedKeybinding } from './monaco-resolved-keybinding';
import { IQuickAccessController } from '@theia/monaco-editor-core/esm/vs/platform/quickinput/common/quickAccess';
import { QuickAccessController } from '@theia/monaco-editor-core/esm/vs/platform/quickinput/browser/quickAccess';
import { ContextKeyService as VSCodeContextKeyService } from '@theia/monaco-editor-core/esm/vs/platform/contextkey/browser/contextKeyService';
import { IContextKey } from '@theia/monaco-editor-core/esm/vs/platform/contextkey/common/contextkey';
import { IListOptions, List } from '@theia/monaco-editor-core/esm/vs/base/browser/ui/list/listWidget';
import * as monaco from '@theia/monaco-editor-core';
import { ResolvedKeybinding } from '@theia/monaco-editor-core/esm/vs/base/common/keybindings';
Expand Down Expand Up @@ -175,8 +176,13 @@ export class MonacoQuickInputImplementation implements IQuickInputService {
document.body.appendChild(this.container);
}

protected inQuickOpen: IContextKey<boolean>;

private initController(): void {
this.controller = new QuickInputController(this.getOptions());
this.inQuickOpen = this.contextKeyService.createKey<boolean>('inQuickOpen', false);
this.onShow(() => { this.inQuickOpen.set(true); });
this.onHide(() => { this.inQuickOpen.set(false); });
this.updateLayout();
}

Expand Down

0 comments on commit d21ae06

Please sign in to comment.