Move defaultValue to KbCtxKey
This commit is contained in:
parent
aadec363cd
commit
dd7c3d4ab0
|
@ -174,7 +174,7 @@ export class View extends ViewEventHandler implements editorBrowser.IView, IDisp
|
|||
// Text Area (The focus will always be in the textarea when the cursor is blinking)
|
||||
this.textArea = <HTMLTextAreaElement>document.createElement('textarea');
|
||||
this._keybindingService = keybindingService.createScoped(this.textArea);
|
||||
this._editorTextFocusContextKey = editorCommon.KEYBINDING_CONTEXT_EDITOR_TEXT_FOCUS.bindTo(this._keybindingService, undefined);
|
||||
this._editorTextFocusContextKey = editorCommon.KEYBINDING_CONTEXT_EDITOR_TEXT_FOCUS.bindTo(this._keybindingService);
|
||||
this.textArea.className = editorBrowser.ClassNames.TEXTAREA;
|
||||
this.textArea.setAttribute('wrap', 'off');
|
||||
this.textArea.setAttribute('autocorrect', 'off');
|
||||
|
|
|
@ -145,12 +145,12 @@ export abstract class CommonCodeEditor extends EventEmitter implements editorCom
|
|||
this._commandService = commandService;
|
||||
this._keybindingService = keybindingService;
|
||||
this._editorIdContextKey = this._keybindingService.createKey('editorId', this.getId());
|
||||
this._editorFocusContextKey = editorCommon.KEYBINDING_CONTEXT_EDITOR_FOCUS.bindTo(this._keybindingService, undefined);
|
||||
this._editorTabMovesFocusKey = editorCommon.KEYBINDING_CONTEXT_EDITOR_TAB_MOVES_FOCUS.bindTo(this._keybindingService, false);
|
||||
this._editorReadonly = editorCommon.KEYBINDING_CONTEXT_EDITOR_READONLY.bindTo(this._keybindingService, false);
|
||||
this._hasMultipleSelectionsKey = editorCommon.KEYBINDING_CONTEXT_EDITOR_HAS_MULTIPLE_SELECTIONS.bindTo(this._keybindingService, false);
|
||||
this._hasNonEmptySelectionKey = editorCommon.KEYBINDING_CONTEXT_EDITOR_HAS_NON_EMPTY_SELECTION.bindTo(this._keybindingService, false);
|
||||
this._langIdKey = editorCommon.KEYBINDING_CONTEXT_EDITOR_LANGUAGE_ID.bindTo(this._keybindingService, undefined);
|
||||
this._editorFocusContextKey = editorCommon.KEYBINDING_CONTEXT_EDITOR_FOCUS.bindTo(this._keybindingService);
|
||||
this._editorTabMovesFocusKey = editorCommon.KEYBINDING_CONTEXT_EDITOR_TAB_MOVES_FOCUS.bindTo(this._keybindingService);
|
||||
this._editorReadonly = editorCommon.KEYBINDING_CONTEXT_EDITOR_READONLY.bindTo(this._keybindingService);
|
||||
this._hasMultipleSelectionsKey = editorCommon.KEYBINDING_CONTEXT_EDITOR_HAS_MULTIPLE_SELECTIONS.bindTo(this._keybindingService);
|
||||
this._hasNonEmptySelectionKey = editorCommon.KEYBINDING_CONTEXT_EDITOR_HAS_NON_EMPTY_SELECTION.bindTo(this._keybindingService);
|
||||
this._langIdKey = editorCommon.KEYBINDING_CONTEXT_EDITOR_LANGUAGE_ID.bindTo(this._keybindingService);
|
||||
this._lifetimeDispose.push(new EditorModeContext(this, this._keybindingService));
|
||||
|
||||
this._decorationTypeKeysToIds = {};
|
||||
|
|
|
@ -3021,37 +3021,37 @@ export interface IDiffLineInformation {
|
|||
* A context key that is set when the editor's text has focus (cursor is blinking).
|
||||
* @internal
|
||||
*/
|
||||
export const KEYBINDING_CONTEXT_EDITOR_TEXT_FOCUS = new KbCtxKey('editorTextFocus');
|
||||
export const KEYBINDING_CONTEXT_EDITOR_TEXT_FOCUS = new KbCtxKey<boolean>('editorTextFocus', undefined);
|
||||
|
||||
/**
|
||||
* A context key that is set when the editor's text or an editor's widget has focus.
|
||||
* @internal
|
||||
*/
|
||||
export const KEYBINDING_CONTEXT_EDITOR_FOCUS = new KbCtxKey('editorFocus');
|
||||
export const KEYBINDING_CONTEXT_EDITOR_FOCUS = new KbCtxKey<boolean>('editorFocus', undefined);
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export const KEYBINDING_CONTEXT_EDITOR_TAB_MOVES_FOCUS = new KbCtxKey('editorTabMovesFocus');
|
||||
export const KEYBINDING_CONTEXT_EDITOR_TAB_MOVES_FOCUS = new KbCtxKey<boolean>('editorTabMovesFocus', false);
|
||||
/**
|
||||
* A context key that is set when the editor's text is readonly.
|
||||
* @internal
|
||||
*/
|
||||
export const KEYBINDING_CONTEXT_EDITOR_READONLY = new KbCtxKey('editorReadonly');
|
||||
export const KEYBINDING_CONTEXT_EDITOR_READONLY = new KbCtxKey<boolean>('editorReadonly', false);
|
||||
/**
|
||||
* A context key that is set when the editor has multiple selections (multiple cursors).
|
||||
* @internal
|
||||
*/
|
||||
export const KEYBINDING_CONTEXT_EDITOR_HAS_MULTIPLE_SELECTIONS = new KbCtxKey('editorHasMultipleSelections');
|
||||
export const KEYBINDING_CONTEXT_EDITOR_HAS_MULTIPLE_SELECTIONS = new KbCtxKey<boolean>('editorHasMultipleSelections', false);
|
||||
/**
|
||||
* A context key that is set when the editor has a non-collapsed selection.
|
||||
* @internal
|
||||
*/
|
||||
export const KEYBINDING_CONTEXT_EDITOR_HAS_NON_EMPTY_SELECTION = new KbCtxKey('editorHasSelection');
|
||||
export const KEYBINDING_CONTEXT_EDITOR_HAS_NON_EMPTY_SELECTION = new KbCtxKey<boolean>('editorHasSelection', false);
|
||||
/**
|
||||
* A context key that is set to the language associated with the model associated with the editor.
|
||||
* @internal
|
||||
*/
|
||||
export const KEYBINDING_CONTEXT_EDITOR_LANGUAGE_ID = new KbCtxKey('editorLangId');
|
||||
export const KEYBINDING_CONTEXT_EDITOR_LANGUAGE_ID = new KbCtxKey<string>('editorLangId', undefined);
|
||||
|
||||
/**
|
||||
* @internal
|
||||
|
@ -3101,47 +3101,47 @@ export namespace ModeContextKeys {
|
|||
/**
|
||||
* @internal
|
||||
*/
|
||||
export const hasCompletionItemProvider = new KbCtxKey('editorHasCompletionItemProvider');
|
||||
export const hasCompletionItemProvider = new KbCtxKey<boolean>('editorHasCompletionItemProvider', undefined);
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export const hasCodeActionsProvider = new KbCtxKey('editorHasCodeActionsProvider');
|
||||
export const hasCodeActionsProvider = new KbCtxKey<boolean>('editorHasCodeActionsProvider', undefined);
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export const hasCodeLensProvider = new KbCtxKey('editorHasCodeLensProvider');
|
||||
export const hasCodeLensProvider = new KbCtxKey<boolean>('editorHasCodeLensProvider', undefined);
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export const hasDefinitionProvider = new KbCtxKey('editorHasDefinitionProvider');
|
||||
export const hasDefinitionProvider = new KbCtxKey<boolean>('editorHasDefinitionProvider', undefined);
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export const hasHoverProvider = new KbCtxKey('editorHasHoverProvider');
|
||||
export const hasHoverProvider = new KbCtxKey<boolean>('editorHasHoverProvider', undefined);
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export const hasDocumentHighlightProvider = new KbCtxKey('editorHasDocumentHighlightProvider');
|
||||
export const hasDocumentHighlightProvider = new KbCtxKey<boolean>('editorHasDocumentHighlightProvider', undefined);
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export const hasDocumentSymbolProvider = new KbCtxKey('editorHasDocumentSymbolProvider');
|
||||
export const hasDocumentSymbolProvider = new KbCtxKey<boolean>('editorHasDocumentSymbolProvider', undefined);
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export const hasReferenceProvider = new KbCtxKey('editorHasReferenceProvider');
|
||||
export const hasReferenceProvider = new KbCtxKey<boolean>('editorHasReferenceProvider', undefined);
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export const hasRenameProvider = new KbCtxKey('editorHasRenameProvider');
|
||||
export const hasRenameProvider = new KbCtxKey<boolean>('editorHasRenameProvider', undefined);
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export const hasFormattingProvider = new KbCtxKey('editorHasFormattingProvider');
|
||||
export const hasFormattingProvider = new KbCtxKey<boolean>('editorHasFormattingProvider', undefined);
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export const hasSignatureHelpProvider = new KbCtxKey('editorHasSignatureHelpProvider');
|
||||
export const hasSignatureHelpProvider = new KbCtxKey<boolean>('editorHasSignatureHelpProvider', undefined);
|
||||
}
|
||||
|
||||
export class BareFontInfo {
|
||||
|
|
|
@ -32,17 +32,17 @@ export class EditorModeContext {
|
|||
) {
|
||||
this._editor = editor;
|
||||
|
||||
this._hasCompletionItemProvider = ModeContextKeys.hasCompletionItemProvider.bindTo(keybindingService, undefined);
|
||||
this._hasCodeActionsProvider = ModeContextKeys.hasCodeActionsProvider.bindTo(keybindingService, undefined);
|
||||
this._hasCodeLensProvider = ModeContextKeys.hasCodeLensProvider.bindTo(keybindingService, undefined);
|
||||
this._hasDefinitionProvider = ModeContextKeys.hasDefinitionProvider.bindTo(keybindingService, undefined);
|
||||
this._hasHoverProvider = ModeContextKeys.hasHoverProvider.bindTo(keybindingService, undefined);
|
||||
this._hasDocumentHighlightProvider = ModeContextKeys.hasDocumentHighlightProvider.bindTo(keybindingService, undefined);
|
||||
this._hasDocumentSymbolProvider = ModeContextKeys.hasDocumentSymbolProvider.bindTo(keybindingService, undefined);
|
||||
this._hasReferenceProvider = ModeContextKeys.hasReferenceProvider.bindTo(keybindingService, undefined);
|
||||
this._hasRenameProvider = ModeContextKeys.hasRenameProvider.bindTo(keybindingService, undefined);
|
||||
this._hasFormattingProvider = ModeContextKeys.hasFormattingProvider.bindTo(keybindingService, undefined);
|
||||
this._hasSignatureHelpProvider = ModeContextKeys.hasSignatureHelpProvider.bindTo(keybindingService, undefined);
|
||||
this._hasCompletionItemProvider = ModeContextKeys.hasCompletionItemProvider.bindTo(keybindingService);
|
||||
this._hasCodeActionsProvider = ModeContextKeys.hasCodeActionsProvider.bindTo(keybindingService);
|
||||
this._hasCodeLensProvider = ModeContextKeys.hasCodeLensProvider.bindTo(keybindingService);
|
||||
this._hasDefinitionProvider = ModeContextKeys.hasDefinitionProvider.bindTo(keybindingService);
|
||||
this._hasHoverProvider = ModeContextKeys.hasHoverProvider.bindTo(keybindingService);
|
||||
this._hasDocumentHighlightProvider = ModeContextKeys.hasDocumentHighlightProvider.bindTo(keybindingService);
|
||||
this._hasDocumentSymbolProvider = ModeContextKeys.hasDocumentSymbolProvider.bindTo(keybindingService);
|
||||
this._hasReferenceProvider = ModeContextKeys.hasReferenceProvider.bindTo(keybindingService);
|
||||
this._hasRenameProvider = ModeContextKeys.hasRenameProvider.bindTo(keybindingService);
|
||||
this._hasFormattingProvider = ModeContextKeys.hasFormattingProvider.bindTo(keybindingService);
|
||||
this._hasSignatureHelpProvider = ModeContextKeys.hasSignatureHelpProvider.bindTo(keybindingService);
|
||||
|
||||
// update when model/mode changes
|
||||
this._disposables.push(editor.onDidChangeModel(() => this._update()));
|
||||
|
|
|
@ -24,7 +24,7 @@ import {ICodeEditor, IOverlayWidget, IOverlayWidgetPosition} from 'vs/editor/bro
|
|||
import {EditorBrowserRegistry} from 'vs/editor/browser/editorBrowserExtensions';
|
||||
import {ToggleTabFocusModeAction} from 'vs/editor/contrib/toggleTabFocusMode/common/toggleTabFocusMode';
|
||||
|
||||
const CONTEXT_ACCESSIBILITY_WIDGET_VISIBLE = new KbCtxKey('accessibilityHelpWidgetVisible');
|
||||
const CONTEXT_ACCESSIBILITY_WIDGET_VISIBLE = new KbCtxKey<boolean>('accessibilityHelpWidgetVisible', false);
|
||||
const TOGGLE_EXPERIMENTAL_SCREEN_READER_SUPPORT_COMMAND_ID = 'toggleExperimentalScreenReaderSupport';
|
||||
|
||||
class AccessibilityHelpController extends Disposable implements IEditorContribution {
|
||||
|
@ -75,7 +75,7 @@ class AccessibilityHelpWidget extends Widget implements IOverlayWidget {
|
|||
|
||||
this._editor = editor;
|
||||
this._keybindingService = keybindingService;
|
||||
this._isVisibleKey = CONTEXT_ACCESSIBILITY_WIDGET_VISIBLE.bindTo(keybindingService, false);
|
||||
this._isVisibleKey = CONTEXT_ACCESSIBILITY_WIDGET_VISIBLE.bindTo(keybindingService);
|
||||
|
||||
this._domNode = document.createElement('div');
|
||||
this._domNode.className = 'accessibilityHelpWidget';
|
||||
|
|
|
@ -33,7 +33,7 @@ export interface IFindStartOptions {
|
|||
shouldAnimate:boolean;
|
||||
}
|
||||
|
||||
export const CONTEXT_FIND_WIDGET_VISIBLE = new KbCtxKey('findWidgetVisible');
|
||||
export const CONTEXT_FIND_WIDGET_VISIBLE = new KbCtxKey<boolean>('findWidgetVisible', false);
|
||||
export const CONTEXT_FIND_WIDGET_NOT_VISIBLE = CONTEXT_FIND_WIDGET_VISIBLE.toNegated();
|
||||
|
||||
export class CommonFindController extends Disposable implements editorCommon.IEditorContribution {
|
||||
|
@ -52,7 +52,7 @@ export class CommonFindController extends Disposable implements editorCommon.IEd
|
|||
constructor(editor:editorCommon.ICommonCodeEditor, @IKeybindingService keybindingService: IKeybindingService) {
|
||||
super();
|
||||
this._editor = editor;
|
||||
this._findWidgetVisible = CONTEXT_FIND_WIDGET_VISIBLE.bindTo(keybindingService, false);
|
||||
this._findWidgetVisible = CONTEXT_FIND_WIDGET_VISIBLE.bindTo(keybindingService);
|
||||
|
||||
this._state = this._register(new FindReplaceState());
|
||||
this._register(this._state.addChangeListener((e) => this._onStateChanged(e)));
|
||||
|
|
|
@ -454,7 +454,7 @@ class MarkerController implements editorCommon.IEditorContribution {
|
|||
@ICommandService private _commandService: ICommandService
|
||||
) {
|
||||
this._editor = editor;
|
||||
this._markersNavigationVisible = CONTEXT_MARKERS_NAVIGATION_VISIBLE.bindTo(this._keybindingService, false);
|
||||
this._markersNavigationVisible = CONTEXT_MARKERS_NAVIGATION_VISIBLE.bindTo(this._keybindingService);
|
||||
}
|
||||
|
||||
public getId(): string {
|
||||
|
@ -544,7 +544,7 @@ class PrevMarkerAction extends MarkerNavigationAction {
|
|||
}
|
||||
}
|
||||
|
||||
var CONTEXT_MARKERS_NAVIGATION_VISIBLE = new KbCtxKey('markersNavigationVisible');
|
||||
var CONTEXT_MARKERS_NAVIGATION_VISIBLE = new KbCtxKey<boolean>('markersNavigationVisible', false);
|
||||
|
||||
const MarkerCommand = EditorCommand.bindToContribution<MarkerController>(
|
||||
MarkerController.getMarkerController, {
|
||||
|
|
|
@ -178,8 +178,8 @@ export class ParameterHintsWidget implements IContentWidget, IDisposable {
|
|||
|
||||
constructor(private editor: ICodeEditor, @IKeybindingService keybindingService: IKeybindingService) {
|
||||
this.model = new ParameterHintsModel(editor);
|
||||
this.keyVisible = Context.Visible.bindTo(keybindingService, false);
|
||||
this.keyMultipleSignatures = Context.MultipleSignatures.bindTo(keybindingService, false);
|
||||
this.keyVisible = Context.Visible.bindTo(keybindingService);
|
||||
this.keyMultipleSignatures = Context.MultipleSignatures.bindTo(keybindingService);
|
||||
this.visible = false;
|
||||
this.disposables = [];
|
||||
|
||||
|
|
|
@ -14,8 +14,8 @@ import { Position } from 'vs/editor/common/core/position';
|
|||
import { KbCtxKey } from 'vs/platform/keybinding/common/keybinding';
|
||||
|
||||
export const Context = {
|
||||
Visible: new KbCtxKey('parameterHintsVisible'),
|
||||
MultipleSignatures: new KbCtxKey('parameterHintsMultipleSignatures'),
|
||||
Visible: new KbCtxKey<boolean>('parameterHintsVisible', false),
|
||||
MultipleSignatures: new KbCtxKey<boolean>('parameterHintsMultipleSignatures', false),
|
||||
};
|
||||
|
||||
export function provideSignatureHelp(model:IReadOnlyModel, position:Position): TPromise<SignatureHelp> {
|
||||
|
|
|
@ -46,7 +46,7 @@ export class QuickFixController implements IEditorContribution {
|
|||
this.editor = editor;
|
||||
this.model = new QuickFixModel(this.editor, this._markerService, this.onAccept.bind(this));
|
||||
|
||||
this.quickFixWidgetVisible = CONTEXT_QUICK_FIX_WIDGET_VISIBLE.bindTo(this._keybindingService, false);
|
||||
this.quickFixWidgetVisible = CONTEXT_QUICK_FIX_WIDGET_VISIBLE.bindTo(this._keybindingService);
|
||||
this.suggestWidget = new QuickFixSelectionWidget(this.editor, telemetryService,() => {
|
||||
this.quickFixWidgetVisible.set(true);
|
||||
},() => {
|
||||
|
@ -143,7 +143,7 @@ export class QuickFixAction extends EditorAction {
|
|||
}
|
||||
}
|
||||
|
||||
var CONTEXT_QUICK_FIX_WIDGET_VISIBLE = new KbCtxKey('quickFixWidgetVisible');
|
||||
var CONTEXT_QUICK_FIX_WIDGET_VISIBLE = new KbCtxKey<boolean>('quickFixWidgetVisible', false);
|
||||
|
||||
const QuickFixCommand = EditorCommand.bindToContribution<QuickFixController>(
|
||||
QuickFixController.getQuickFixController, {
|
||||
|
|
|
@ -43,7 +43,7 @@ export class ReferenceController implements editorCommon.IEditorContribution {
|
|||
@optional(IPeekViewService) peekViewService: IPeekViewService
|
||||
) {
|
||||
if (peekViewService) {
|
||||
peekViewService.contextKey.bindTo(keybindingService, true);
|
||||
peekViewService.contextKey.bindTo(keybindingService);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ import {ReferencesModel, OneReference} from './referencesModel';
|
|||
import {ReferenceWidget, LayoutData} from './referencesWidget';
|
||||
import {Range} from 'vs/editor/common/core/range';
|
||||
|
||||
export const ctxReferenceSearchVisible = new KbCtxKey('referenceSearchVisible');
|
||||
export const ctxReferenceSearchVisible = new KbCtxKey<boolean>('referenceSearchVisible', false);
|
||||
|
||||
export interface RequestOptions {
|
||||
getMetaTitle(model: ReferencesModel): string;
|
||||
|
@ -62,7 +62,7 @@ export class ReferencesController implements editorCommon.IEditorContribution {
|
|||
@optional(IPeekViewService) private _peekViewService: IPeekViewService
|
||||
) {
|
||||
this._editor = editor;
|
||||
this._referenceSearchVisible = ctxReferenceSearchVisible.bindTo(keybindingService, false);
|
||||
this._referenceSearchVisible = ctxReferenceSearchVisible.bindTo(keybindingService);
|
||||
}
|
||||
|
||||
public getId(): string {
|
||||
|
|
|
@ -485,7 +485,7 @@ export interface SelectionEvent {
|
|||
*/
|
||||
export class ReferenceWidget extends PeekViewWidget {
|
||||
|
||||
public static INNER_EDITOR_CONTEXT_KEY = new KbCtxKey('inReferenceSearchEditor');
|
||||
public static INNER_EDITOR_CONTEXT_KEY = new KbCtxKey<boolean>('inReferenceSearchEditor', true);
|
||||
|
||||
private _model: ReferencesModel;
|
||||
private _decorationsManager: DecorationsManager;
|
||||
|
|
|
@ -26,7 +26,7 @@ import RenameInputField from './renameInputField';
|
|||
|
||||
// --- register actions and commands
|
||||
|
||||
const CONTEXT_RENAME_INPUT_VISIBLE = new KbCtxKey('renameInputVisible');
|
||||
const CONTEXT_RENAME_INPUT_VISIBLE = new KbCtxKey<boolean>('renameInputVisible', false);
|
||||
|
||||
class RenameController implements IEditorContribution {
|
||||
|
||||
|
@ -48,7 +48,7 @@ class RenameController implements IEditorContribution {
|
|||
@IKeybindingService keybindingService: IKeybindingService
|
||||
) {
|
||||
this._renameInputField = new RenameInputField(editor);
|
||||
this._renameInputVisible = CONTEXT_RENAME_INPUT_VISIBLE.bindTo(keybindingService, false);
|
||||
this._renameInputVisible = CONTEXT_RENAME_INPUT_VISIBLE.bindTo(keybindingService);
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
|
|
|
@ -744,7 +744,7 @@ class SnippetController implements ISnippetController {
|
|||
constructor(editor: editorCommon.ICommonCodeEditor, @IKeybindingService keybindingService: IKeybindingService) {
|
||||
this._editor = editor;
|
||||
this._currentController = null;
|
||||
this._inSnippetMode = CONTEXT_SNIPPET_MODE.bindTo(keybindingService, false);
|
||||
this._inSnippetMode = CONTEXT_SNIPPET_MODE.bindTo(keybindingService);
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
|
@ -935,7 +935,7 @@ class SnippetController implements ISnippetController {
|
|||
}
|
||||
}
|
||||
|
||||
export var CONTEXT_SNIPPET_MODE = new KbCtxKey('inSnippetMode');
|
||||
export var CONTEXT_SNIPPET_MODE = new KbCtxKey<boolean>('inSnippetMode', false);
|
||||
|
||||
const SnippetCommand = EditorCommand.bindToContribution<ISnippetController>(
|
||||
getSnippetController, {
|
||||
|
|
|
@ -366,9 +366,9 @@ export class SuggestWidget implements IContentWidget, IDisposable {
|
|||
this.model.onDidCancel(e => this.onDidCancel(e))
|
||||
];
|
||||
|
||||
this.suggestWidgetVisible = SuggestContext.Visible.bindTo(keybindingService, false);
|
||||
this.suggestWidgetMultipleSuggestions = SuggestContext.MultipleSuggestions.bindTo(keybindingService, false);
|
||||
this.suggestionSupportsAutoAccept = SuggestContext.AcceptOnKey.bindTo(keybindingService, true);
|
||||
this.suggestWidgetVisible = SuggestContext.Visible.bindTo(keybindingService);
|
||||
this.suggestWidgetMultipleSuggestions = SuggestContext.MultipleSuggestions.bindTo(keybindingService);
|
||||
this.suggestionSupportsAutoAccept = SuggestContext.AcceptOnKey.bindTo(keybindingService);
|
||||
|
||||
this.editor.addContentWidget(this);
|
||||
this.setState(State.Hidden);
|
||||
|
|
|
@ -22,7 +22,7 @@ let snippetsRegistry = <ISnippetsRegistry>Registry.as(Extensions.Snippets);
|
|||
class TabCompletionController implements editorCommon.IEditorContribution {
|
||||
|
||||
static Id = 'editor.tabCompletionController';
|
||||
static ContextKey = new KbCtxKey('hasSnippetCompletions');
|
||||
static ContextKey = new KbCtxKey<boolean>('hasSnippetCompletions', undefined);
|
||||
|
||||
private _snippetController: ISnippetController;
|
||||
private _cursorChangeSubscription: IDisposable;
|
||||
|
@ -33,7 +33,7 @@ class TabCompletionController implements editorCommon.IEditorContribution {
|
|||
@IKeybindingService keybindingService: IKeybindingService
|
||||
) {
|
||||
this._snippetController = getSnippetController(editor);
|
||||
const hasSnippets = TabCompletionController.ContextKey.bindTo(keybindingService, undefined);
|
||||
const hasSnippets = TabCompletionController.ContextKey.bindTo(keybindingService);
|
||||
this._cursorChangeSubscription = editor.onDidChangeCursorSelection(e => {
|
||||
|
||||
this._currentSnippets.length = 0;
|
||||
|
|
|
@ -19,9 +19,9 @@ import {Registry} from 'vs/platform/platform';
|
|||
import {KbCtxKey} from 'vs/platform/keybinding/common/keybinding';
|
||||
|
||||
export const Context = {
|
||||
Visible: new KbCtxKey('suggestWidgetVisible'),
|
||||
MultipleSuggestions: new KbCtxKey('suggestWidgetMultipleSuggestions'),
|
||||
AcceptOnKey: new KbCtxKey('suggestionSupportsAcceptOnKey')
|
||||
Visible: new KbCtxKey<boolean>('suggestWidgetVisible', false),
|
||||
MultipleSuggestions: new KbCtxKey<boolean>('suggestWidgetMultipleSuggestions', false),
|
||||
AcceptOnKey: new KbCtxKey<boolean>('suggestionSupportsAcceptOnKey', true)
|
||||
};
|
||||
|
||||
export interface ISuggestionItem {
|
||||
|
|
|
@ -26,7 +26,7 @@ export var IPeekViewService = createDecorator<IPeekViewService>('peekViewService
|
|||
export interface IPeekViewService {
|
||||
_serviceBrand: any;
|
||||
isActive: boolean;
|
||||
contextKey: KbCtxKey;
|
||||
contextKey: KbCtxKey<boolean>;
|
||||
}
|
||||
|
||||
export function getOuterEditor(accessor: ServicesAccessor, args: any): ICommonCodeEditor {
|
||||
|
@ -40,7 +40,7 @@ export function getOuterEditor(accessor: ServicesAccessor, args: any): ICommonCo
|
|||
export class PeekViewWidget extends ZoneWidget implements IPeekViewService {
|
||||
|
||||
public _serviceBrand: any;
|
||||
public contextKey: KbCtxKey;
|
||||
public contextKey: KbCtxKey<boolean>;
|
||||
|
||||
private _onDidClose = new Emitter<PeekViewWidget>();
|
||||
private _isActive = false;
|
||||
|
@ -52,7 +52,7 @@ export class PeekViewWidget extends ZoneWidget implements IPeekViewService {
|
|||
protected _actionbarWidget: ActionBar;
|
||||
protected _bodyElement: HTMLDivElement;
|
||||
|
||||
constructor(editor: ICodeEditor, contextKey: KbCtxKey, options: IOptions = {}) {
|
||||
constructor(editor: ICodeEditor, contextKey: KbCtxKey<boolean>, options: IOptions = {}) {
|
||||
super(editor, options);
|
||||
this.contextKey = contextKey;
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
import URI from 'vs/base/common/uri';
|
||||
import Event, {Emitter} from 'vs/base/common/event';
|
||||
import {IDisposable, dispose} from 'vs/base/common/lifecycle';
|
||||
import {IAction} from 'vs/base/common/actions';
|
||||
|
@ -101,7 +100,7 @@ class Menu implements IMenu {
|
|||
const activeActions: MenuItemAction[] = [];
|
||||
for (let action of actions) {
|
||||
if (this._keybindingService.contextMatchesRules(action.item.when)) {
|
||||
action.resource = ResourceContextKey.Resource.getValue<URI>(this._keybindingService);
|
||||
action.resource = ResourceContextKey.Resource.getValue(this._keybindingService);
|
||||
activeActions.push(action);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,9 +11,9 @@ import {IModeService} from 'vs/editor/common/services/modeService';
|
|||
export class ResourceContextKey implements IKeybindingContextKey<URI> {
|
||||
|
||||
|
||||
static Scheme = new KbCtxKey('resourceScheme');
|
||||
static LangId = new KbCtxKey('resourceLangId');
|
||||
static Resource = new KbCtxKey('resource');
|
||||
static Scheme = new KbCtxKey<string>('resourceScheme', undefined);
|
||||
static LangId = new KbCtxKey<string>('resourceLangId', undefined);
|
||||
static Resource = new KbCtxKey<URI>('resource', undefined);
|
||||
|
||||
private _resourceKey: IKeybindingContextKey<URI>;
|
||||
private _schemeKey: IKeybindingContextKey<string>;
|
||||
|
@ -23,9 +23,9 @@ export class ResourceContextKey implements IKeybindingContextKey<URI> {
|
|||
@IKeybindingService keybindingService: IKeybindingService,
|
||||
@IModeService private _modeService: IModeService
|
||||
) {
|
||||
this._schemeKey = ResourceContextKey.Scheme.bindTo(keybindingService, undefined);
|
||||
this._langIdKey = ResourceContextKey.LangId.bindTo(keybindingService, undefined);
|
||||
this._resourceKey = ResourceContextKey.Resource.bindTo(keybindingService, undefined);
|
||||
this._schemeKey = ResourceContextKey.Scheme.bindTo(keybindingService);
|
||||
this._langIdKey = ResourceContextKey.LangId.bindTo(keybindingService);
|
||||
this._resourceKey = ResourceContextKey.Resource.bindTo(keybindingService);
|
||||
}
|
||||
|
||||
set(value: URI) {
|
||||
|
|
|
@ -369,17 +369,20 @@ export class KbAndExpression implements KbExpr {
|
|||
}
|
||||
}
|
||||
|
||||
export class KbCtxKey extends KbDefinedExpression {
|
||||
export class KbCtxKey<T> extends KbDefinedExpression {
|
||||
|
||||
constructor(key:string) {
|
||||
private _defaultValue: T;
|
||||
|
||||
constructor(key:string, defaultValue:T) {
|
||||
super(key);
|
||||
this._defaultValue = defaultValue;
|
||||
}
|
||||
|
||||
public bindTo<T>(target:IKeybindingService, defaultValue:T): IKeybindingContextKey<T> {
|
||||
return target.createKey(this.key, defaultValue);
|
||||
public bindTo(target:IKeybindingService): IKeybindingContextKey<T> {
|
||||
return target.createKey(this.key, this._defaultValue);
|
||||
}
|
||||
|
||||
public getValue<T>(target:IKeybindingService): T {
|
||||
public getValue(target:IKeybindingService): T {
|
||||
return target.getContextValue<T>(this.key);
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ import {IModeService} from 'vs/editor/common/services/modeService';
|
|||
import {KbCtxKey, IKeybindingService, IKeybindingContextKey} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {IThemeService} from 'vs/workbench/services/themes/common/themeService';
|
||||
|
||||
export const TextCompareEditorVisible = new KbCtxKey('textCompareEditorVisible');
|
||||
export const TextCompareEditorVisible = new KbCtxKey<boolean>('textCompareEditorVisible', false);
|
||||
|
||||
/**
|
||||
* The text editor that leverages the diff text editor for the editing experience.
|
||||
|
@ -68,7 +68,7 @@ export class TextDiffEditor extends BaseTextEditor {
|
|||
) {
|
||||
super(TextDiffEditor.ID, telemetryService, instantiationService, contextService, storageService, messageService, configurationService, eventService, editorService, modeService, themeService);
|
||||
|
||||
this.textDiffEditorVisible = TextCompareEditorVisible.bindTo(keybindingService, false);
|
||||
this.textDiffEditorVisible = TextCompareEditorVisible.bindTo(keybindingService);
|
||||
}
|
||||
|
||||
public getTitle(): string {
|
||||
|
|
|
@ -43,7 +43,7 @@ import {IKeybindingService, KbCtxKey, IKeybindingContextKey} from 'vs/platform/k
|
|||
import {IHistoryService} from 'vs/workbench/services/history/common/history';
|
||||
|
||||
const HELP_PREFIX = '?';
|
||||
const QUICK_OPEN_MODE = new KbCtxKey('inQuickOpen');
|
||||
const QUICK_OPEN_MODE = new KbCtxKey<boolean>('inQuickOpen', false);
|
||||
|
||||
interface IPickOpenEntryItem extends IPickOpenEntry {
|
||||
height?: number;
|
||||
|
@ -103,7 +103,7 @@ export class QuickOpenController extends WorkbenchComponent implements IQuickOpe
|
|||
|
||||
this.promisesToCompleteOnHide = [];
|
||||
|
||||
this.inQuickOpenMode = QUICK_OPEN_MODE.bindTo(keybindingService, false);
|
||||
this.inQuickOpenMode = QUICK_OPEN_MODE.bindTo(keybindingService);
|
||||
|
||||
this._onShow = new Emitter<void>();
|
||||
this._onHide = new Emitter<void>();
|
||||
|
|
|
@ -68,8 +68,8 @@ import {IMenuService} from 'vs/platform/actions/common/actions';
|
|||
import {MenuService} from 'vs/platform/actions/common/menuService';
|
||||
import {IContextMenuService} from 'vs/platform/contextview/browser/contextView';
|
||||
|
||||
export const MessagesVisibleContext = new KbCtxKey('globalMessageVisible');
|
||||
export const EditorsVisibleContext = new KbCtxKey('editorIsOpen');
|
||||
export const MessagesVisibleContext = new KbCtxKey<boolean>('globalMessageVisible', false);
|
||||
export const EditorsVisibleContext = new KbCtxKey<boolean>('editorIsOpen', false);
|
||||
export const NoEditorsVisibleContext:KbExpr = EditorsVisibleContext.toNegated();
|
||||
|
||||
interface WorkbenchParams {
|
||||
|
@ -203,8 +203,8 @@ export class Workbench implements IPartService {
|
|||
}
|
||||
|
||||
// Contexts
|
||||
this.messagesVisibleContext = MessagesVisibleContext.bindTo(this.keybindingService, false);
|
||||
this.editorsVisibleContext = EditorsVisibleContext.bindTo(this.keybindingService, false);
|
||||
this.messagesVisibleContext = MessagesVisibleContext.bindTo(this.keybindingService);
|
||||
this.editorsVisibleContext = EditorsVisibleContext.bindTo(this.keybindingService);
|
||||
|
||||
// Register Listeners
|
||||
this.registerListeners();
|
||||
|
|
|
@ -23,7 +23,7 @@ import debug = require('vs/workbench/parts/debug/common/debug');
|
|||
import {IKeyboardEvent} from 'vs/base/browser/keyboardEvent';
|
||||
|
||||
const $ = dom.emmet;
|
||||
const CONTEXT_BREAKPOINT_WIDGET_VISIBLE = new KbCtxKey('breakpointWidgetVisible');
|
||||
const CONTEXT_BREAKPOINT_WIDGET_VISIBLE = new KbCtxKey<boolean>('breakpointWidgetVisible', false);
|
||||
const CLOSE_BREAKPOINT_WIDGET_COMMAND_ID = 'closeBreakpointWidget';
|
||||
|
||||
export class BreakpointWidget extends ZoneWidget {
|
||||
|
@ -43,7 +43,7 @@ export class BreakpointWidget extends ZoneWidget {
|
|||
|
||||
this.toDispose = [];
|
||||
this.create();
|
||||
this.breakpointWidgetVisible = CONTEXT_BREAKPOINT_WIDGET_VISIBLE.bindTo(keybindingService, false);
|
||||
this.breakpointWidgetVisible = CONTEXT_BREAKPOINT_WIDGET_VISIBLE.bindTo(keybindingService);
|
||||
this.breakpointWidgetVisible.set(true);
|
||||
BreakpointWidget.INSTANCE = this;
|
||||
this.toDispose.push(editor.onDidChangeModel(() => this.dispose()));
|
||||
|
|
|
@ -16,7 +16,7 @@ import {KbCtxKey, KbExpr} from 'vs/platform/keybinding/common/keybinding';
|
|||
export const VIEWLET_ID = 'workbench.view.debug';
|
||||
export const REPL_ID = 'workbench.panel.repl';
|
||||
export const DEBUG_SERVICE_ID = 'debugService';
|
||||
export const CONTEXT_IN_DEBUG_MODE = new KbCtxKey('inDebugMode');
|
||||
export const CONTEXT_IN_DEBUG_MODE = new KbCtxKey<boolean>('inDebugMode', false);
|
||||
export const CONTEXT_NOT_IN_DEBUG_MODE:KbExpr = CONTEXT_IN_DEBUG_MODE.toNegated();
|
||||
export const EDITOR_CONTRIBUTION_ID = 'editor.contrib.debug';
|
||||
|
||||
|
|
|
@ -109,7 +109,7 @@ export class DebugService implements debug.IDebugService {
|
|||
this._state = debug.State.Disabled;
|
||||
}
|
||||
this.configurationManager = this.instantiationService.createInstance(ConfigurationManager, this.storageService.get(DEBUG_SELECTED_CONFIG_NAME_KEY, StorageScope.WORKSPACE, 'null'));
|
||||
this.inDebugMode = debug.CONTEXT_IN_DEBUG_MODE.bindTo(keybindingService, false);
|
||||
this.inDebugMode = debug.CONTEXT_IN_DEBUG_MODE.bindTo(keybindingService);
|
||||
|
||||
this.model = new model.Model(this.loadBreakpoints(), this.storageService.getBoolean(DEBUG_BREAKPOINTS_ACTIVATED_KEY, StorageScope.WORKSPACE, true), this.loadFunctionBreakpoints(),
|
||||
this.loadExceptionBreakpoints(), this.loadWatchExpressions());
|
||||
|
|
|
@ -65,7 +65,7 @@ export class ExplorerViewlet extends Viewlet {
|
|||
this.views = [];
|
||||
|
||||
this.viewletState = new FileViewletState();
|
||||
this.viewletVisibleContextKey = ExplorerViewletVisible.bindTo<boolean>(keybindingService, true);
|
||||
this.viewletVisibleContextKey = ExplorerViewletVisible.bindTo(keybindingService);
|
||||
|
||||
this.viewletSettings = this.getMemento(storageService, Scope.WORKSPACE);
|
||||
this.configurationService.onDidUpdateConfiguration(e => this.onConfigurationUpdated(e.config));
|
||||
|
|
|
@ -21,7 +21,7 @@ import {KbCtxKey} from 'vs/platform/keybinding/common/keybinding';
|
|||
*/
|
||||
export const VIEWLET_ID = 'workbench.view.explorer';
|
||||
|
||||
export const ExplorerViewletVisible = new KbCtxKey('explorerViewletVisible');
|
||||
export const ExplorerViewletVisible = new KbCtxKey<boolean>('explorerViewletVisible', true);
|
||||
|
||||
/**
|
||||
* File editor input id.
|
||||
|
|
|
@ -105,7 +105,7 @@ export class SearchViewlet extends Viewlet {
|
|||
super(VIEWLET_ID, telemetryService);
|
||||
|
||||
this.toDispose = [];
|
||||
this.viewletVisible = SearchViewletVisible.bindTo(keybindingService, true);
|
||||
this.viewletVisible = SearchViewletVisible.bindTo(keybindingService);
|
||||
this.callOnModelChange = [];
|
||||
|
||||
this.queryBuilder = this.instantiationService.createInstance(QueryBuilder);
|
||||
|
|
|
@ -63,7 +63,7 @@ class ReplaceAllAction extends Action {
|
|||
|
||||
export class SearchWidget extends Widget {
|
||||
|
||||
static REPLACE_ACTIVE_CONTEXT_KEY= new KbCtxKey('replaceActive');
|
||||
static REPLACE_ACTIVE_CONTEXT_KEY= new KbCtxKey<boolean>('replaceActive', false);
|
||||
private static REPLACE_ALL_DISABLED_LABEL= nls.localize('search.action.replaceAll.disabled.label', "Replace All (Submit Search to Enable)");
|
||||
private static REPLACE_ALL_ENABLED_LABEL=(keyBindingService: IKeybindingService):string=>{
|
||||
let keybindings = keyBindingService.lookupKeybindings(ReplaceAllAction.ID);
|
||||
|
@ -103,7 +103,7 @@ export class SearchWidget extends Widget {
|
|||
constructor(container: Builder, private contextViewService: IContextViewService, options: ISearchWidgetOptions= Object.create(null),
|
||||
private keyBindingService: IKeybindingService, private instantiationService: IInstantiationService) {
|
||||
super();
|
||||
this.replaceActive = SearchWidget.REPLACE_ACTIVE_CONTEXT_KEY.bindTo(this.keyBindingService, false);
|
||||
this.replaceActive = SearchWidget.REPLACE_ACTIVE_CONTEXT_KEY.bindTo(this.keyBindingService);
|
||||
this.render(container, options);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,4 +7,4 @@ import {KbCtxKey} from 'vs/platform/keybinding/common/keybinding';
|
|||
|
||||
export const VIEWLET_ID = 'workbench.view.search';
|
||||
|
||||
export const SearchViewletVisible = new KbCtxKey('searchViewletVisible');
|
||||
export const SearchViewletVisible = new KbCtxKey<boolean>('searchViewletVisible', true);
|
||||
|
|
|
@ -24,7 +24,7 @@ export const TERMINAL_DEFAULT_SHELL_WINDOWS = processes.getWindowsShell();
|
|||
/**
|
||||
* A context key that is set when the integrated terminal has focus.
|
||||
*/
|
||||
export const KEYBINDING_CONTEXT_TERMINAL_FOCUS = new KbCtxKey('terminalFocus');
|
||||
export const KEYBINDING_CONTEXT_TERMINAL_FOCUS = new KbCtxKey<boolean>('terminalFocus', undefined);
|
||||
export const KEYBINDING_CONTEXT_TERMINAL_NOT_FOCUSED:KbExpr = KEYBINDING_CONTEXT_TERMINAL_FOCUS.toNegated();
|
||||
|
||||
export const ITerminalService = createDecorator<ITerminalService>(TERMINAL_SERVICE_ID);
|
||||
|
|
|
@ -49,7 +49,7 @@ export class TerminalService implements ITerminalService {
|
|||
this._onActiveInstanceChanged = new Emitter<string>();
|
||||
this._onInstancesChanged = new Emitter<string>();
|
||||
this._onInstanceTitleChanged = new Emitter<string>();
|
||||
this._terminalFocusContextKey = KEYBINDING_CONTEXT_TERMINAL_FOCUS.bindTo(this.keybindingService, undefined);
|
||||
this._terminalFocusContextKey = KEYBINDING_CONTEXT_TERMINAL_FOCUS.bindTo(this.keybindingService);
|
||||
}
|
||||
|
||||
public get onActiveInstanceChanged(): Event<string> {
|
||||
|
|
Loading…
Reference in a new issue