diff --git a/src/vs/editor/browser/view/viewImpl.ts b/src/vs/editor/browser/view/viewImpl.ts index dcfb81ee24f..af88f267e24 100644 --- a/src/vs/editor/browser/view/viewImpl.ts +++ b/src/vs/editor/browser/view/viewImpl.ts @@ -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 = 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'); diff --git a/src/vs/editor/common/commonCodeEditor.ts b/src/vs/editor/common/commonCodeEditor.ts index 109259b361f..e0dcd813e99 100644 --- a/src/vs/editor/common/commonCodeEditor.ts +++ b/src/vs/editor/common/commonCodeEditor.ts @@ -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 = {}; diff --git a/src/vs/editor/common/editorCommon.ts b/src/vs/editor/common/editorCommon.ts index 8ee34ce787f..b4eee81fa3b 100644 --- a/src/vs/editor/common/editorCommon.ts +++ b/src/vs/editor/common/editorCommon.ts @@ -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('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('editorFocus', undefined); /** * @internal */ -export const KEYBINDING_CONTEXT_EDITOR_TAB_MOVES_FOCUS = new KbCtxKey('editorTabMovesFocus'); +export const KEYBINDING_CONTEXT_EDITOR_TAB_MOVES_FOCUS = new KbCtxKey('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('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('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('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('editorLangId', undefined); /** * @internal @@ -3101,47 +3101,47 @@ export namespace ModeContextKeys { /** * @internal */ - export const hasCompletionItemProvider = new KbCtxKey('editorHasCompletionItemProvider'); + export const hasCompletionItemProvider = new KbCtxKey('editorHasCompletionItemProvider', undefined); /** * @internal */ - export const hasCodeActionsProvider = new KbCtxKey('editorHasCodeActionsProvider'); + export const hasCodeActionsProvider = new KbCtxKey('editorHasCodeActionsProvider', undefined); /** * @internal */ - export const hasCodeLensProvider = new KbCtxKey('editorHasCodeLensProvider'); + export const hasCodeLensProvider = new KbCtxKey('editorHasCodeLensProvider', undefined); /** * @internal */ - export const hasDefinitionProvider = new KbCtxKey('editorHasDefinitionProvider'); + export const hasDefinitionProvider = new KbCtxKey('editorHasDefinitionProvider', undefined); /** * @internal */ - export const hasHoverProvider = new KbCtxKey('editorHasHoverProvider'); + export const hasHoverProvider = new KbCtxKey('editorHasHoverProvider', undefined); /** * @internal */ - export const hasDocumentHighlightProvider = new KbCtxKey('editorHasDocumentHighlightProvider'); + export const hasDocumentHighlightProvider = new KbCtxKey('editorHasDocumentHighlightProvider', undefined); /** * @internal */ - export const hasDocumentSymbolProvider = new KbCtxKey('editorHasDocumentSymbolProvider'); + export const hasDocumentSymbolProvider = new KbCtxKey('editorHasDocumentSymbolProvider', undefined); /** * @internal */ - export const hasReferenceProvider = new KbCtxKey('editorHasReferenceProvider'); + export const hasReferenceProvider = new KbCtxKey('editorHasReferenceProvider', undefined); /** * @internal */ - export const hasRenameProvider = new KbCtxKey('editorHasRenameProvider'); + export const hasRenameProvider = new KbCtxKey('editorHasRenameProvider', undefined); /** * @internal */ - export const hasFormattingProvider = new KbCtxKey('editorHasFormattingProvider'); + export const hasFormattingProvider = new KbCtxKey('editorHasFormattingProvider', undefined); /** * @internal */ - export const hasSignatureHelpProvider = new KbCtxKey('editorHasSignatureHelpProvider'); + export const hasSignatureHelpProvider = new KbCtxKey('editorHasSignatureHelpProvider', undefined); } export class BareFontInfo { diff --git a/src/vs/editor/common/modes/editorModeContext.ts b/src/vs/editor/common/modes/editorModeContext.ts index 7b84e3bedce..d34313a5e87 100644 --- a/src/vs/editor/common/modes/editorModeContext.ts +++ b/src/vs/editor/common/modes/editorModeContext.ts @@ -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())); diff --git a/src/vs/editor/contrib/accessibility/browser/accessibility.ts b/src/vs/editor/contrib/accessibility/browser/accessibility.ts index ae8ec6591d1..f49138c2292 100644 --- a/src/vs/editor/contrib/accessibility/browser/accessibility.ts +++ b/src/vs/editor/contrib/accessibility/browser/accessibility.ts @@ -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('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'; diff --git a/src/vs/editor/contrib/find/common/findController.ts b/src/vs/editor/contrib/find/common/findController.ts index d9317d93574..651004d0062 100644 --- a/src/vs/editor/contrib/find/common/findController.ts +++ b/src/vs/editor/contrib/find/common/findController.ts @@ -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('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))); diff --git a/src/vs/editor/contrib/gotoError/browser/gotoError.ts b/src/vs/editor/contrib/gotoError/browser/gotoError.ts index c92925b53b4..6f6a03f006a 100644 --- a/src/vs/editor/contrib/gotoError/browser/gotoError.ts +++ b/src/vs/editor/contrib/gotoError/browser/gotoError.ts @@ -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('markersNavigationVisible', false); const MarkerCommand = EditorCommand.bindToContribution( MarkerController.getMarkerController, { diff --git a/src/vs/editor/contrib/parameterHints/browser/parameterHintsWidget.ts b/src/vs/editor/contrib/parameterHints/browser/parameterHintsWidget.ts index fe309501c4b..71200ad5328 100644 --- a/src/vs/editor/contrib/parameterHints/browser/parameterHintsWidget.ts +++ b/src/vs/editor/contrib/parameterHints/browser/parameterHintsWidget.ts @@ -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 = []; diff --git a/src/vs/editor/contrib/parameterHints/common/parameterHints.ts b/src/vs/editor/contrib/parameterHints/common/parameterHints.ts index a2e293b369f..fd9c2164545 100644 --- a/src/vs/editor/contrib/parameterHints/common/parameterHints.ts +++ b/src/vs/editor/contrib/parameterHints/common/parameterHints.ts @@ -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('parameterHintsVisible', false), + MultipleSignatures: new KbCtxKey('parameterHintsMultipleSignatures', false), }; export function provideSignatureHelp(model:IReadOnlyModel, position:Position): TPromise { diff --git a/src/vs/editor/contrib/quickFix/browser/quickFix.ts b/src/vs/editor/contrib/quickFix/browser/quickFix.ts index 97fb5b2aa3c..48839d53787 100644 --- a/src/vs/editor/contrib/quickFix/browser/quickFix.ts +++ b/src/vs/editor/contrib/quickFix/browser/quickFix.ts @@ -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('quickFixWidgetVisible', false); const QuickFixCommand = EditorCommand.bindToContribution( QuickFixController.getQuickFixController, { diff --git a/src/vs/editor/contrib/referenceSearch/browser/referenceSearch.ts b/src/vs/editor/contrib/referenceSearch/browser/referenceSearch.ts index a8d885e022d..80b4d102dc2 100644 --- a/src/vs/editor/contrib/referenceSearch/browser/referenceSearch.ts +++ b/src/vs/editor/contrib/referenceSearch/browser/referenceSearch.ts @@ -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); } } diff --git a/src/vs/editor/contrib/referenceSearch/browser/referencesController.ts b/src/vs/editor/contrib/referenceSearch/browser/referencesController.ts index b902bea5c22..77940ebce81 100644 --- a/src/vs/editor/contrib/referenceSearch/browser/referencesController.ts +++ b/src/vs/editor/contrib/referenceSearch/browser/referencesController.ts @@ -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('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 { diff --git a/src/vs/editor/contrib/referenceSearch/browser/referencesWidget.ts b/src/vs/editor/contrib/referenceSearch/browser/referencesWidget.ts index 6c4c823fe51..e82a1598923 100644 --- a/src/vs/editor/contrib/referenceSearch/browser/referencesWidget.ts +++ b/src/vs/editor/contrib/referenceSearch/browser/referencesWidget.ts @@ -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('inReferenceSearchEditor', true); private _model: ReferencesModel; private _decorationsManager: DecorationsManager; diff --git a/src/vs/editor/contrib/rename/browser/rename.ts b/src/vs/editor/contrib/rename/browser/rename.ts index 87278752af0..74d3ee870f9 100644 --- a/src/vs/editor/contrib/rename/browser/rename.ts +++ b/src/vs/editor/contrib/rename/browser/rename.ts @@ -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('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 { diff --git a/src/vs/editor/contrib/snippet/common/snippet.ts b/src/vs/editor/contrib/snippet/common/snippet.ts index 8dbb81e1c31..9b1d848b0ae 100644 --- a/src/vs/editor/contrib/snippet/common/snippet.ts +++ b/src/vs/editor/contrib/snippet/common/snippet.ts @@ -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('inSnippetMode', false); const SnippetCommand = EditorCommand.bindToContribution( getSnippetController, { diff --git a/src/vs/editor/contrib/suggest/browser/suggestWidget.ts b/src/vs/editor/contrib/suggest/browser/suggestWidget.ts index 97d04e9dc1e..4b1c75c6cfe 100644 --- a/src/vs/editor/contrib/suggest/browser/suggestWidget.ts +++ b/src/vs/editor/contrib/suggest/browser/suggestWidget.ts @@ -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); diff --git a/src/vs/editor/contrib/suggest/browser/tabCompletion.ts b/src/vs/editor/contrib/suggest/browser/tabCompletion.ts index 715b3ef1d61..062fceb06ca 100644 --- a/src/vs/editor/contrib/suggest/browser/tabCompletion.ts +++ b/src/vs/editor/contrib/suggest/browser/tabCompletion.ts @@ -22,7 +22,7 @@ let snippetsRegistry = Registry.as(Extensions.Snippets); class TabCompletionController implements editorCommon.IEditorContribution { static Id = 'editor.tabCompletionController'; - static ContextKey = new KbCtxKey('hasSnippetCompletions'); + static ContextKey = new KbCtxKey('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; diff --git a/src/vs/editor/contrib/suggest/common/suggest.ts b/src/vs/editor/contrib/suggest/common/suggest.ts index 603489970c6..3c7ecb0e219 100644 --- a/src/vs/editor/contrib/suggest/common/suggest.ts +++ b/src/vs/editor/contrib/suggest/common/suggest.ts @@ -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('suggestWidgetVisible', false), + MultipleSuggestions: new KbCtxKey('suggestWidgetMultipleSuggestions', false), + AcceptOnKey: new KbCtxKey('suggestionSupportsAcceptOnKey', true) }; export interface ISuggestionItem { diff --git a/src/vs/editor/contrib/zoneWidget/browser/peekViewWidget.ts b/src/vs/editor/contrib/zoneWidget/browser/peekViewWidget.ts index afaccc35a92..5cd8f6a2fef 100644 --- a/src/vs/editor/contrib/zoneWidget/browser/peekViewWidget.ts +++ b/src/vs/editor/contrib/zoneWidget/browser/peekViewWidget.ts @@ -26,7 +26,7 @@ export var IPeekViewService = createDecorator('peekViewService export interface IPeekViewService { _serviceBrand: any; isActive: boolean; - contextKey: KbCtxKey; + contextKey: KbCtxKey; } 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; private _onDidClose = new Emitter(); 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, options: IOptions = {}) { super(editor, options); this.contextKey = contextKey; } diff --git a/src/vs/platform/actions/common/menuService.ts b/src/vs/platform/actions/common/menuService.ts index 9b3ec668962..30ce157f5bd 100644 --- a/src/vs/platform/actions/common/menuService.ts +++ b/src/vs/platform/actions/common/menuService.ts @@ -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(this._keybindingService); + action.resource = ResourceContextKey.Resource.getValue(this._keybindingService); activeActions.push(action); } } diff --git a/src/vs/platform/actions/common/resourceContextKey.ts b/src/vs/platform/actions/common/resourceContextKey.ts index dfb5f62830d..45340cc91f5 100644 --- a/src/vs/platform/actions/common/resourceContextKey.ts +++ b/src/vs/platform/actions/common/resourceContextKey.ts @@ -11,9 +11,9 @@ import {IModeService} from 'vs/editor/common/services/modeService'; export class ResourceContextKey implements IKeybindingContextKey { - static Scheme = new KbCtxKey('resourceScheme'); - static LangId = new KbCtxKey('resourceLangId'); - static Resource = new KbCtxKey('resource'); + static Scheme = new KbCtxKey('resourceScheme', undefined); + static LangId = new KbCtxKey('resourceLangId', undefined); + static Resource = new KbCtxKey('resource', undefined); private _resourceKey: IKeybindingContextKey; private _schemeKey: IKeybindingContextKey; @@ -23,9 +23,9 @@ export class ResourceContextKey implements IKeybindingContextKey { @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) { diff --git a/src/vs/platform/keybinding/common/keybinding.ts b/src/vs/platform/keybinding/common/keybinding.ts index 7075e2dda14..302014858da 100644 --- a/src/vs/platform/keybinding/common/keybinding.ts +++ b/src/vs/platform/keybinding/common/keybinding.ts @@ -369,17 +369,20 @@ export class KbAndExpression implements KbExpr { } } -export class KbCtxKey extends KbDefinedExpression { +export class KbCtxKey extends KbDefinedExpression { - constructor(key:string) { + private _defaultValue: T; + + constructor(key:string, defaultValue:T) { super(key); + this._defaultValue = defaultValue; } - public bindTo(target:IKeybindingService, defaultValue:T): IKeybindingContextKey { - return target.createKey(this.key, defaultValue); + public bindTo(target:IKeybindingService): IKeybindingContextKey { + return target.createKey(this.key, this._defaultValue); } - public getValue(target:IKeybindingService): T { + public getValue(target:IKeybindingService): T { return target.getContextValue(this.key); } diff --git a/src/vs/workbench/browser/parts/editor/textDiffEditor.ts b/src/vs/workbench/browser/parts/editor/textDiffEditor.ts index 3dca41ab60d..7b200beb811 100644 --- a/src/vs/workbench/browser/parts/editor/textDiffEditor.ts +++ b/src/vs/workbench/browser/parts/editor/textDiffEditor.ts @@ -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('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 { diff --git a/src/vs/workbench/browser/parts/quickopen/quickOpenController.ts b/src/vs/workbench/browser/parts/quickopen/quickOpenController.ts index 78ed12cde45..166164158bf 100644 --- a/src/vs/workbench/browser/parts/quickopen/quickOpenController.ts +++ b/src/vs/workbench/browser/parts/quickopen/quickOpenController.ts @@ -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('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(); this._onHide = new Emitter(); diff --git a/src/vs/workbench/electron-browser/workbench.ts b/src/vs/workbench/electron-browser/workbench.ts index 6f717b77e8b..06a04c07fc1 100644 --- a/src/vs/workbench/electron-browser/workbench.ts +++ b/src/vs/workbench/electron-browser/workbench.ts @@ -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('globalMessageVisible', false); +export const EditorsVisibleContext = new KbCtxKey('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(); diff --git a/src/vs/workbench/parts/debug/browser/breakpointWidget.ts b/src/vs/workbench/parts/debug/browser/breakpointWidget.ts index 0eb87be7d94..5b7f1b213b2 100644 --- a/src/vs/workbench/parts/debug/browser/breakpointWidget.ts +++ b/src/vs/workbench/parts/debug/browser/breakpointWidget.ts @@ -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('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())); diff --git a/src/vs/workbench/parts/debug/common/debug.ts b/src/vs/workbench/parts/debug/common/debug.ts index e9768948aa1..9e055fba8a3 100644 --- a/src/vs/workbench/parts/debug/common/debug.ts +++ b/src/vs/workbench/parts/debug/common/debug.ts @@ -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('inDebugMode', false); export const CONTEXT_NOT_IN_DEBUG_MODE:KbExpr = CONTEXT_IN_DEBUG_MODE.toNegated(); export const EDITOR_CONTRIBUTION_ID = 'editor.contrib.debug'; diff --git a/src/vs/workbench/parts/debug/electron-browser/debugService.ts b/src/vs/workbench/parts/debug/electron-browser/debugService.ts index 63aaab9ba12..2b8a925f314 100644 --- a/src/vs/workbench/parts/debug/electron-browser/debugService.ts +++ b/src/vs/workbench/parts/debug/electron-browser/debugService.ts @@ -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()); diff --git a/src/vs/workbench/parts/files/browser/explorerViewlet.ts b/src/vs/workbench/parts/files/browser/explorerViewlet.ts index 2631b84c9e0..bf720310833 100644 --- a/src/vs/workbench/parts/files/browser/explorerViewlet.ts +++ b/src/vs/workbench/parts/files/browser/explorerViewlet.ts @@ -65,7 +65,7 @@ export class ExplorerViewlet extends Viewlet { this.views = []; this.viewletState = new FileViewletState(); - this.viewletVisibleContextKey = ExplorerViewletVisible.bindTo(keybindingService, true); + this.viewletVisibleContextKey = ExplorerViewletVisible.bindTo(keybindingService); this.viewletSettings = this.getMemento(storageService, Scope.WORKSPACE); this.configurationService.onDidUpdateConfiguration(e => this.onConfigurationUpdated(e.config)); diff --git a/src/vs/workbench/parts/files/common/files.ts b/src/vs/workbench/parts/files/common/files.ts index d9310ee1124..4d5e864f9d3 100644 --- a/src/vs/workbench/parts/files/common/files.ts +++ b/src/vs/workbench/parts/files/common/files.ts @@ -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('explorerViewletVisible', true); /** * File editor input id. diff --git a/src/vs/workbench/parts/search/browser/searchViewlet.ts b/src/vs/workbench/parts/search/browser/searchViewlet.ts index 8c5e60b2548..a793affe8b0 100644 --- a/src/vs/workbench/parts/search/browser/searchViewlet.ts +++ b/src/vs/workbench/parts/search/browser/searchViewlet.ts @@ -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); diff --git a/src/vs/workbench/parts/search/browser/searchWidget.ts b/src/vs/workbench/parts/search/browser/searchWidget.ts index cdb1a494d54..1137c1cb521 100644 --- a/src/vs/workbench/parts/search/browser/searchWidget.ts +++ b/src/vs/workbench/parts/search/browser/searchWidget.ts @@ -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('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); } diff --git a/src/vs/workbench/parts/search/common/constants.ts b/src/vs/workbench/parts/search/common/constants.ts index b7423483a7f..6710c749f4a 100644 --- a/src/vs/workbench/parts/search/common/constants.ts +++ b/src/vs/workbench/parts/search/common/constants.ts @@ -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('searchViewletVisible', true); diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminal.ts b/src/vs/workbench/parts/terminal/electron-browser/terminal.ts index bde560e9c60..806ee3d6339 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/terminal.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/terminal.ts @@ -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('terminalFocus', undefined); export const KEYBINDING_CONTEXT_TERMINAL_NOT_FOCUSED:KbExpr = KEYBINDING_CONTEXT_TERMINAL_FOCUS.toNegated(); export const ITerminalService = createDecorator(TERMINAL_SERVICE_ID); diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminalService.ts b/src/vs/workbench/parts/terminal/electron-browser/terminalService.ts index be45c3cadc8..1e08c032cd3 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/terminalService.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/terminalService.ts @@ -49,7 +49,7 @@ export class TerminalService implements ITerminalService { this._onActiveInstanceChanged = new Emitter(); this._onInstancesChanged = new Emitter(); this._onInstanceTitleChanged = new Emitter(); - this._terminalFocusContextKey = KEYBINDING_CONTEXT_TERMINAL_FOCUS.bindTo(this.keybindingService, undefined); + this._terminalFocusContextKey = KEYBINDING_CONTEXT_TERMINAL_FOCUS.bindTo(this.keybindingService); } public get onActiveInstanceChanged(): Event {