mirror of
https://github.com/Microsoft/vscode
synced 2024-10-06 03:17:00 +00:00
parent
929c645c9a
commit
10bbedca57
|
@ -21,7 +21,6 @@ const HistoryNavigationForwardsEnablementContext = 'historyNavigationForwardsEna
|
|||
const HistoryNavigationBackwardsEnablementContext = 'historyNavigationBackwardsEnabled';
|
||||
|
||||
export interface IHistoryNavigationContext extends IDisposable {
|
||||
scopedContextKeyService: IContextKeyService;
|
||||
historyNavigationForwardsEnablement: IContextKey<boolean>;
|
||||
historyNavigationBackwardsEnablement: IContextKey<boolean>;
|
||||
}
|
||||
|
@ -29,14 +28,13 @@ export interface IHistoryNavigationContext extends IDisposable {
|
|||
let lastFocusedWidget: IHistoryNavigationWidget | undefined = undefined;
|
||||
const widgets: IHistoryNavigationWidget[] = [];
|
||||
|
||||
export function registerAndCreateHistoryNavigationContext(contextKeyService: IContextKeyService, widget: IHistoryNavigationWidget): IHistoryNavigationContext {
|
||||
export function registerAndCreateHistoryNavigationContext(scopedContextKeyService: IContextKeyService, widget: IHistoryNavigationWidget): IHistoryNavigationContext {
|
||||
if (widgets.includes(widget)) {
|
||||
throw new Error('Cannot register the same widget multiple times');
|
||||
}
|
||||
|
||||
widgets.push(widget);
|
||||
const disposableStore = new DisposableStore();
|
||||
const scopedContextKeyService = disposableStore.add(contextKeyService.createScoped(widget.element));
|
||||
const historyNavigationWidgetFocus = new RawContextKey<boolean>(HistoryNavigationWidgetFocusContext, false).bindTo(scopedContextKeyService);
|
||||
const historyNavigationForwardsEnablement = new RawContextKey<boolean>(HistoryNavigationForwardsEnablementContext, true).bindTo(scopedContextKeyService);
|
||||
const historyNavigationBackwardsEnablement = new RawContextKey<boolean>(HistoryNavigationBackwardsEnablementContext, true).bindTo(scopedContextKeyService);
|
||||
|
@ -66,7 +64,6 @@ export function registerAndCreateHistoryNavigationContext(contextKeyService: ICo
|
|||
}));
|
||||
|
||||
return {
|
||||
scopedContextKeyService,
|
||||
historyNavigationForwardsEnablement,
|
||||
historyNavigationBackwardsEnablement,
|
||||
dispose() {
|
||||
|
@ -81,7 +78,8 @@ export class ContextScopedHistoryInputBox extends HistoryInputBox {
|
|||
@IContextKeyService contextKeyService: IContextKeyService
|
||||
) {
|
||||
super(container, contextViewProvider, options);
|
||||
this._register(registerAndCreateHistoryNavigationContext(contextKeyService, this));
|
||||
const scopedContextKeyService = this._register(contextKeyService.createScoped(this.element));
|
||||
this._register(registerAndCreateHistoryNavigationContext(scopedContextKeyService, this));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -92,7 +90,8 @@ export class ContextScopedFindInput extends FindInput {
|
|||
@IContextKeyService contextKeyService: IContextKeyService
|
||||
) {
|
||||
super(container, contextViewProvider, options);
|
||||
this._register(registerAndCreateHistoryNavigationContext(contextKeyService, this.inputBox));
|
||||
const scopedContextKeyService = this._register(contextKeyService.createScoped(this.inputBox.element));
|
||||
this._register(registerAndCreateHistoryNavigationContext(scopedContextKeyService, this.inputBox));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -102,7 +101,8 @@ export class ContextScopedReplaceInput extends ReplaceInput {
|
|||
@IContextKeyService contextKeyService: IContextKeyService, showReplaceOptions: boolean = false
|
||||
) {
|
||||
super(container, contextViewProvider, showReplaceOptions, options);
|
||||
this._register(registerAndCreateHistoryNavigationContext(contextKeyService, this.inputBox));
|
||||
const scopedContextKeyService = this._register(contextKeyService.createScoped(this.inputBox.element));
|
||||
this._register(registerAndCreateHistoryNavigationContext(scopedContextKeyService, this.inputBox));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ import { Extensions as ViewContainerExtensions, IView, IViewDescriptorService, V
|
|||
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { assertIsDefined } from 'vs/base/common/types';
|
||||
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { MenuId, Action2, IAction2Options, IMenuService, SubmenuItemAction } from 'vs/platform/actions/common/actions';
|
||||
import { MenuId, Action2, IAction2Options, SubmenuItemAction } from 'vs/platform/actions/common/actions';
|
||||
import { createActionViewItem } from 'vs/platform/actions/browser/menuEntryActionViewItem';
|
||||
import { parseLinkedText } from 'vs/base/common/linkedText';
|
||||
import { IOpenerService } from 'vs/platform/opener/common/opener';
|
||||
|
@ -149,27 +149,6 @@ class ViewWelcomeController {
|
|||
}
|
||||
}
|
||||
|
||||
class ViewMenuActions extends CompositeMenuActions {
|
||||
constructor(
|
||||
element: HTMLElement,
|
||||
viewId: string,
|
||||
menuId: MenuId,
|
||||
contextMenuId: MenuId,
|
||||
donotForwardArgs: boolean,
|
||||
@IContextKeyService contextKeyService: IContextKeyService,
|
||||
@IMenuService menuService: IMenuService,
|
||||
@IViewDescriptorService viewDescriptorService: IViewDescriptorService,
|
||||
) {
|
||||
const scopedContextKeyService = contextKeyService.createScoped(element);
|
||||
scopedContextKeyService.createKey('view', viewId);
|
||||
const viewLocationKey = scopedContextKeyService.createKey('viewLocation', ViewContainerLocationToString(viewDescriptorService.getViewLocationById(viewId)!));
|
||||
super(menuId, contextMenuId, { shouldForwardArgs: !donotForwardArgs }, scopedContextKeyService, menuService);
|
||||
this._register(scopedContextKeyService);
|
||||
this._register(Event.filter(viewDescriptorService.onDidChangeLocation, e => e.views.some(view => view.id === viewId))(() => viewLocationKey.set(ViewContainerLocationToString(viewDescriptorService.getViewLocationById(viewId)!))));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export abstract class ViewPane extends Pane implements IView {
|
||||
|
||||
private static readonly AlwaysShowActionsConfig = 'workbench.view.alwaysShowHeaderActions';
|
||||
|
@ -202,7 +181,7 @@ export abstract class ViewPane extends Pane implements IView {
|
|||
return this._titleDescription;
|
||||
}
|
||||
|
||||
readonly menuActions: ViewMenuActions;
|
||||
readonly menuActions: CompositeMenuActions;
|
||||
|
||||
private progressBar!: ProgressBar;
|
||||
private progressIndicator!: IProgressIndicator;
|
||||
|
@ -220,6 +199,8 @@ export abstract class ViewPane extends Pane implements IView {
|
|||
private viewWelcomeDisposable: IDisposable = Disposable.None;
|
||||
private viewWelcomeController: ViewWelcomeController;
|
||||
|
||||
protected readonly scopedContextKeyService: IContextKeyService;
|
||||
|
||||
constructor(
|
||||
options: IViewPaneOptions,
|
||||
@IKeybindingService protected keybindingService: IKeybindingService,
|
||||
|
@ -239,7 +220,12 @@ export abstract class ViewPane extends Pane implements IView {
|
|||
this._titleDescription = options.titleDescription;
|
||||
this.showActionsAlways = !!options.showActionsAlways;
|
||||
|
||||
this.menuActions = this._register(this.instantiationService.createInstance(ViewMenuActions, this.element, this.id, options.titleMenuId || MenuId.ViewTitle, MenuId.ViewTitleContext, !!options.donotForwardArgs));
|
||||
this.scopedContextKeyService = this._register(contextKeyService.createScoped(this.element));
|
||||
this.scopedContextKeyService.createKey('view', this.id);
|
||||
const viewLocationKey = this.scopedContextKeyService.createKey('viewLocation', ViewContainerLocationToString(viewDescriptorService.getViewLocationById(this.id)!));
|
||||
this._register(Event.filter(viewDescriptorService.onDidChangeLocation, e => e.views.some(view => view.id === this.id))(() => viewLocationKey.set(ViewContainerLocationToString(viewDescriptorService.getViewLocationById(this.id)!))));
|
||||
|
||||
this.menuActions = this._register(this.instantiationService.createChild(new ServiceCollection([IContextKeyService, this.scopedContextKeyService])).createInstance(CompositeMenuActions, options.titleMenuId ?? MenuId.ViewTitle, MenuId.ViewTitleContext, { shouldForwardArgs: !options.donotForwardArgs }));
|
||||
this._register(this.menuActions.onDidChange(() => this.updateActions()));
|
||||
|
||||
this.viewWelcomeController = new ViewWelcomeController(this.id, contextKeyService);
|
||||
|
@ -680,9 +666,7 @@ export abstract class FilterViewPane extends ViewPane {
|
|||
@ITelemetryService telemetryService: ITelemetryService,
|
||||
) {
|
||||
super(options, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService);
|
||||
const scopedContextKeyService = this._register(contextKeyService.createScoped(this.element));
|
||||
scopedContextKeyService.createKey('view', options.id);
|
||||
this.filterWidget = this._register(instantiationService.createChild(new ServiceCollection([IContextKeyService, scopedContextKeyService])).createInstance(FilterWidget, options.filterOptions));
|
||||
this.filterWidget = this._register(instantiationService.createChild(new ServiceCollection([IContextKeyService, this.scopedContextKeyService])).createInstance(FilterWidget, options.filterOptions));
|
||||
}
|
||||
|
||||
override getFilterWidget(): FilterWidget {
|
||||
|
|
|
@ -418,12 +418,13 @@ export class ContextScopedSuggestEnabledInputWithHistory extends SuggestEnabledI
|
|||
}
|
||||
|
||||
protected override getScopedContextKeyService(contextKeyService: IContextKeyService) {
|
||||
const scopedContextKeyService = this._register(contextKeyService.createScoped(this.element));
|
||||
this.historyContext = this._register(registerAndCreateHistoryNavigationContext(
|
||||
contextKeyService,
|
||||
scopedContextKeyService,
|
||||
this,
|
||||
));
|
||||
|
||||
return this.historyContext.scopedContextKeyService;
|
||||
return scopedContextKeyService;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -623,14 +623,14 @@ export class Repl extends FilterViewPane implements IHistoryNavigationWidget {
|
|||
this.replInputContainer = dom.append(container, $('.repl-input-wrapper'));
|
||||
dom.append(this.replInputContainer, $('.repl-input-chevron' + ThemeIcon.asCSSSelector(debugConsoleEvaluationPrompt)));
|
||||
|
||||
const { scopedContextKeyService, historyNavigationBackwardsEnablement, historyNavigationForwardsEnablement } = this._register(registerAndCreateHistoryNavigationContext(this.contextKeyService, this));
|
||||
const { historyNavigationBackwardsEnablement, historyNavigationForwardsEnablement } = this._register(registerAndCreateHistoryNavigationContext(this.scopedContextKeyService, this));
|
||||
this.setHistoryNavigationEnablement = enabled => {
|
||||
historyNavigationBackwardsEnablement.set(enabled);
|
||||
historyNavigationForwardsEnablement.set(enabled);
|
||||
};
|
||||
CONTEXT_IN_DEBUG_REPL.bindTo(scopedContextKeyService).set(true);
|
||||
CONTEXT_IN_DEBUG_REPL.bindTo(this.scopedContextKeyService).set(true);
|
||||
|
||||
this.scopedInstantiationService = this.instantiationService.createChild(new ServiceCollection([IContextKeyService, scopedContextKeyService]));
|
||||
this.scopedInstantiationService = this.instantiationService.createChild(new ServiceCollection([IContextKeyService, this.scopedContextKeyService]));
|
||||
const options = getSimpleEditorOptions();
|
||||
options.readOnly = true;
|
||||
options.suggest = { showStatusBar: true };
|
||||
|
|
Loading…
Reference in a new issue