提交 c3e3e532 编写于 作者: S Sandeep Somavarapu

💄

上级 7399f842
......@@ -8,7 +8,7 @@ import { IContextKeyService, ContextKeyDefinedExpr, ContextKeyExpr, ContextKeyAn
import { HistoryInputBox, IHistoryInputOptions } from 'vs/base/browser/ui/inputbox/inputBox';
import { FindInput, IFindInputOptions } from 'vs/base/browser/ui/findinput/findInput';
import { IContextViewProvider } from 'vs/base/browser/ui/contextview/contextview';
import { IContextScopedWidget, getContextScopedWidget, createWidgetScopedContextKeyService } from 'vs/platform/widget/common/contextScopedWidget';
import { IContextScopedWidget, getContextScopedWidget, createWidgetScopedContextKeyService, bindContextScopedWidget } from 'vs/platform/widget/common/contextScopedWidget';
import { IHistoryNavigationWidget } from 'vs/base/browser/history';
import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry';
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
......@@ -22,10 +22,10 @@ export interface IContextScopedHistoryNavigationWidget extends IContextScopedWid
}
export function createHistoryNavigationWidgetScopedContextKeyService(contextKeyService: IContextKeyService, widget: IContextScopedHistoryNavigationWidget): IContextKeyService {
const scopedContextKeyService = createWidgetScopedContextKeyService(contextKeyService, widget, HistoryNavigationWidgetContext);
const enablementContext = new RawContextKey<boolean>(HistoryNavigationEnablementContext, true);
enablementContext.bindTo(scopedContextKeyService);
export function createAndBindHistoryNavigationWidgetScopedContextKeyService(contextKeyService: IContextKeyService, widget: IContextScopedHistoryNavigationWidget): IContextKeyService {
const scopedContextKeyService = createWidgetScopedContextKeyService(contextKeyService, widget);
bindContextScopedWidget(scopedContextKeyService, widget, HistoryNavigationWidgetContext);
new RawContextKey<boolean>(HistoryNavigationEnablementContext, true).bindTo(scopedContextKeyService);
return scopedContextKeyService;
}
......@@ -35,7 +35,7 @@ export class ContextScopedHistoryInputBox extends HistoryInputBox {
@IContextKeyService contextKeyService: IContextKeyService
) {
super(container, contextViewProvider, options);
this._register(createHistoryNavigationWidgetScopedContextKeyService(contextKeyService, <IContextScopedHistoryNavigationWidget>{ target: this.element, historyNavigator: this }));
this._register(createAndBindHistoryNavigationWidgetScopedContextKeyService(contextKeyService, <IContextScopedHistoryNavigationWidget>{ target: this.element, historyNavigator: this }));
}
}
......@@ -46,7 +46,7 @@ export class ContextScopedFindInput extends FindInput {
@IContextKeyService contextKeyService: IContextKeyService
) {
super(container, contextViewProvider, options);
this._register(createHistoryNavigationWidgetScopedContextKeyService(contextKeyService, <IContextScopedHistoryNavigationWidget>{ target: this.inputBox.element, historyNavigator: this.inputBox }));
this._register(createAndBindHistoryNavigationWidgetScopedContextKeyService(contextKeyService, <IContextScopedHistoryNavigationWidget>{ target: this.inputBox.element, historyNavigator: this.inputBox }));
}
}
......
......@@ -6,11 +6,12 @@
import { IContextKeyService, RawContextKey, IContextKeyServiceTarget } from 'vs/platform/contextkey/common/contextkey';
export function createWidgetScopedContextKeyService(contextKeyService: IContextKeyService, widget: IContextScopedWidget, contextKey: string): IContextKeyService {
const result = contextKeyService.createScoped(widget.target);
const widgetContext = new RawContextKey<IContextScopedWidget>(contextKey, widget);
widgetContext.bindTo(result);
return result;
export function bindContextScopedWidget(contextKeyService: IContextKeyService, widget: IContextScopedWidget, contextKey: string): void {
new RawContextKey<IContextScopedWidget>(contextKey, widget).bindTo(contextKeyService);
}
export function createWidgetScopedContextKeyService(contextKeyService: IContextKeyService, widget: IContextScopedWidget): IContextKeyService {
return contextKeyService.createScoped(widget.target);
}
export function getContextScopedWidget<T extends IContextScopedWidget>(contextKeyService: IContextKeyService, contextKey: string): T {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册