Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migrate search to use new setting #89190

Merged
merged 5 commits into from Jan 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/vs/workbench/browser/parts/views/customView.ts
Expand Up @@ -13,7 +13,7 @@ import { IContextMenuService } from 'vs/platform/contextview/browser/contextView
import { IMenuService, MenuId, MenuItemAction } from 'vs/platform/actions/common/actions';
import { ContextAwareMenuEntryActionViewItem, createAndFillInContextMenuActions } from 'vs/platform/actions/browser/menuEntryActionViewItem';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { ITreeView, ITreeItem, TreeItemCollapsibleState, ITreeViewDataProvider, TreeViewItemHandleArg, ITreeViewDescriptor, IViewsRegistry, ViewContainer, ITreeItemLabel, Extensions } from 'vs/workbench/common/views';
import { ITreeView, ITreeItem, TreeItemCollapsibleState, ITreeViewDataProvider, TreeViewItemHandleArg, ITreeViewDescriptor, IViewsRegistry, ViewContainer, ITreeItemLabel, Extensions, IViewDescriptorService } from 'vs/workbench/common/views';
import { IViewletViewOptions } from 'vs/workbench/browser/parts/views/viewsViewlet';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { INotificationService } from 'vs/platform/notification/common/notification';
Expand Down Expand Up @@ -54,9 +54,10 @@ export class CustomTreeViewPane extends ViewPane {
@IContextMenuService contextMenuService: IContextMenuService,
@IConfigurationService configurationService: IConfigurationService,
@IContextKeyService contextKeyService: IContextKeyService,
@IViewDescriptorService viewDescriptorService: IViewDescriptorService,
@IInstantiationService instantiationService: IInstantiationService,
) {
super({ ...(options as IViewPaneOptions), ariaHeaderLabel: options.title, titleMenuId: MenuId.ViewTitle }, keybindingService, contextMenuService, configurationService, contextKeyService, instantiationService);
super({ ...(options as IViewPaneOptions), ariaHeaderLabel: options.title, titleMenuId: MenuId.ViewTitle }, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService);
const { treeView } = (<ITreeViewDescriptor>Registry.as<IViewsRegistry>(Extensions.ViewsRegistry).getView(options.id));
this.treeView = treeView;
this._register(this.treeView.onDidChangeActions(() => this.updateActions(), this));
Expand Down
17 changes: 13 additions & 4 deletions src/vs/workbench/browser/parts/views/viewPaneContainer.ts
Expand Up @@ -8,7 +8,7 @@ import * as nls from 'vs/nls';
import { Event, Emitter } from 'vs/base/common/event';
import { ColorIdentifier } from 'vs/platform/theme/common/colorRegistry';
import { attachStyler, IColorMapping } from 'vs/platform/theme/common/styler';
import { SIDE_BAR_DRAG_AND_DROP_BACKGROUND, SIDE_BAR_SECTION_HEADER_FOREGROUND, SIDE_BAR_SECTION_HEADER_BACKGROUND, SIDE_BAR_SECTION_HEADER_BORDER } from 'vs/workbench/common/theme';
import { SIDE_BAR_DRAG_AND_DROP_BACKGROUND, SIDE_BAR_SECTION_HEADER_FOREGROUND, SIDE_BAR_SECTION_HEADER_BACKGROUND, SIDE_BAR_SECTION_HEADER_BORDER, PANEL_BACKGROUND, SIDE_BAR_BACKGROUND } from 'vs/workbench/common/theme';
import { append, $, trackFocus, toggleClass, EventType, isAncestor, Dimension, addDisposableListener } from 'vs/base/browser/dom';
import { IDisposable, combinedDisposable, dispose, toDisposable } from 'vs/base/common/lifecycle';
import { firstIndex } from 'vs/base/common/arrays';
Expand All @@ -25,7 +25,7 @@ import { PaneView, IPaneViewOptions, IPaneOptions, Pane, DefaultPaneDndControlle
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService';
import { StandardMouseEvent } from 'vs/base/browser/mouseEvent';
import { Extensions as ViewContainerExtensions, IView, FocusedViewContext, IViewContainersRegistry, IViewDescriptor, ViewContainer, IViewDescriptorService } from 'vs/workbench/common/views';
import { Extensions as ViewContainerExtensions, IView, FocusedViewContext, IViewContainersRegistry, IViewDescriptor, ViewContainer, IViewDescriptorService, ViewContainerLocation, IViewPaneContainer } from 'vs/workbench/common/views';
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { assertIsDefined } from 'vs/base/common/types';
Expand All @@ -34,7 +34,6 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import { IViewletViewOptions } from 'vs/workbench/browser/parts/views/viewsViewlet';
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { IViewPaneContainer } from 'vs/workbench/common/viewPaneContainer';
import { Component } from 'vs/workbench/common/component';
import { MenuId, MenuItemAction } from 'vs/platform/actions/common/actions';
import { ContextAwareMenuEntryActionViewItem } from 'vs/platform/actions/browser/menuEntryActionViewItem';
Expand Down Expand Up @@ -92,6 +91,7 @@ export abstract class ViewPane extends Pane implements IView {
@IContextMenuService protected contextMenuService: IContextMenuService,
@IConfigurationService protected readonly configurationService: IConfigurationService,
@IContextKeyService contextKeyService: IContextKeyService,
@IViewDescriptorService private viewDescriptorService: IViewDescriptorService,
@IInstantiationService protected instantiationService: IInstantiationService,
) {
super(options);
Expand Down Expand Up @@ -189,6 +189,14 @@ export abstract class ViewPane extends Pane implements IView {
this._onDidChangeTitleArea.fire();
}

protected getProgressLocation(): string {
return this.viewDescriptorService.getViewContainer(this.id)!.id;
}

protected getBackgroundColor(): string {
return this.viewDescriptorService.getViewLocation(this.id) === ViewContainerLocation.Panel ? PANEL_BACKGROUND : SIDE_BAR_BACKGROUND;
}

focus(): void {
if (this.element) {
this.element.focus();
Expand Down Expand Up @@ -602,13 +610,14 @@ export class ViewPaneContainer extends Component implements IViewPaneContainer {

protected onDidAddViews(added: IAddedViewDescriptorRef[]): ViewPane[] {
const panesToAdd: { pane: ViewPane, size: number, index: number }[] = [];

for (const { viewDescriptor, collapsed, index, size } of added) {
const pane = this.createView(viewDescriptor,
{
id: viewDescriptor.id,
title: viewDescriptor.name,
actionRunner: this.getActionRunner(),
expanded: !collapsed
expanded: !collapsed,
});

pane.render();
Expand Down
22 changes: 22 additions & 0 deletions src/vs/workbench/browser/parts/views/views.ts
Expand Up @@ -23,6 +23,7 @@ import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { IPaneComposite } from 'vs/workbench/common/panecomposite';
import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
import type { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { PaneComposite } from 'vs/workbench/browser/panecomposite';

export interface IViewState {
visibleGlobal: boolean | undefined;
Expand Down Expand Up @@ -565,6 +566,27 @@ export class ViewsService extends Disposable implements IViewsService {
return undefined;
}

getActiveViewWithId(id: string): IView | null {
const viewContainer = this.viewDescriptorService.getViewContainer(id);
if (viewContainer) {
const location = this.viewContainersRegistry.getViewContainerLocation(viewContainer);

if (location === ViewContainerLocation.Sidebar) {
const activeViewlet = this.viewletService.getActiveViewlet();
if (activeViewlet?.getId() === viewContainer.id) {
return activeViewlet.getViewPaneContainer().getView(id) ?? null;
}
} else if (location === ViewContainerLocation.Panel) {
const activePanel = this.panelService.getActivePanel();
if (activePanel?.getId() === viewContainer.id && activePanel instanceof PaneComposite) {
return activePanel.getViewPaneContainer().getView(id) ?? null;
}
}
}

return null;
}

async openView(id: string, focus: boolean): Promise<IView | null> {
const viewContainer = this.viewDescriptorService.getViewContainer(id);
if (viewContainer) {
Expand Down
3 changes: 1 addition & 2 deletions src/vs/workbench/common/panecomposite.ts
Expand Up @@ -3,9 +3,8 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { IView } from 'vs/workbench/common/views';
import { IView, IViewPaneContainer } from 'vs/workbench/common/views';
import { IComposite } from 'vs/workbench/common/composite';
import { IViewPaneContainer } from 'vs/workbench/common/viewPaneContainer';

export interface IPaneComposite extends IComposite {
openView(id: string, focus?: boolean): IView;
Expand Down
16 changes: 0 additions & 16 deletions src/vs/workbench/common/viewPaneContainer.ts

This file was deleted.

19 changes: 17 additions & 2 deletions src/vs/workbench/common/views.ts
Expand Up @@ -15,10 +15,9 @@ import { ThemeIcon } from 'vs/platform/theme/common/themeService';
import { values, keys, getOrSet } from 'vs/base/common/map';
import { Registry } from 'vs/platform/registry/common/platform';
import { IKeybindings } from 'vs/platform/keybinding/common/keybindingsRegistry';
import { IAction } from 'vs/base/common/actions';
import { IAction, IActionViewItem } from 'vs/base/common/actions';
import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions';
import { flatten } from 'vs/base/common/arrays';
import { IViewPaneContainer } from 'vs/workbench/common/viewPaneContainer';
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';

export const TEST_VIEW_CONTAINER_ID = 'workbench.view.extension.test';
Expand Down Expand Up @@ -357,6 +356,8 @@ export const IViewsService = createDecorator<IViewsService>('viewsService');
export interface IViewsService {
_serviceBrand: undefined;

getActiveViewWithId(id: string): IView | null;

openView(id: string, focus?: boolean): Promise<IView | null>;
}

Expand All @@ -375,6 +376,8 @@ export interface IViewDescriptorService {

getViewContainer(viewId: string): ViewContainer | null;

getViewLocation(viewId: string): ViewContainerLocation | null;

getDefaultContainer(viewId: string): ViewContainer | null;
}

Expand Down Expand Up @@ -505,3 +508,15 @@ export interface IEditableData {
startingValue?: string | null;
onFinish: (value: string, success: boolean) => void;
}

export interface IViewPaneContainer {
setVisible(visible: boolean): void;
isVisible(): boolean;
focus(): void;
getActions(): IAction[];
getSecondaryActions(): IAction[];
getActionViewItem(action: IAction): IActionViewItem | undefined;
getView(viewId: string): IView | undefined;
saveState(): void;
}

4 changes: 3 additions & 1 deletion src/vs/workbench/contrib/bulkEdit/browser/bulkEditPane.ts
Expand Up @@ -36,6 +36,7 @@ import { CancellationToken } from 'vs/base/common/cancellation';
import { ITextEditorOptions } from 'vs/platform/editor/common/editor';
import type { IAsyncDataTreeViewState } from 'vs/base/browser/ui/tree/asyncDataTree';
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
import { IViewDescriptorService } from 'vs/workbench/common/views';

const enum State {
Data = 'data',
Expand Down Expand Up @@ -76,13 +77,14 @@ export class BulkEditPane extends ViewPane {
@IContextMenuService private readonly _contextMenuService: IContextMenuService,
@IContextKeyService private readonly _contextKeyService: IContextKeyService,
@IStorageService private readonly _storageService: IStorageService,
@IViewDescriptorService viewDescriptorService: IViewDescriptorService,
@IKeybindingService keybindingService: IKeybindingService,
@IContextMenuService contextMenuService: IContextMenuService,
@IConfigurationService configurationService: IConfigurationService,
) {
super(
{ ...options, titleMenuId: MenuId.BulkEditTitle },
keybindingService, contextMenuService, configurationService, _contextKeyService, _instaService
keybindingService, contextMenuService, configurationService, _contextKeyService, viewDescriptorService, _instaService
);

this.element.classList.add('bulk-edit-panel', 'show-file-icons');
Expand Down
4 changes: 3 additions & 1 deletion src/vs/workbench/contrib/debug/browser/breakpointsView.ts
Expand Up @@ -33,6 +33,7 @@ import { ILabelService } from 'vs/platform/label/common/label';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { SIDE_BAR_BACKGROUND } from 'vs/workbench/common/theme';
import { Gesture } from 'vs/base/browser/touch';
import { IViewDescriptorService } from 'vs/workbench/common/views';

const $ = dom.$;

Expand Down Expand Up @@ -66,9 +67,10 @@ export class BreakpointsView extends ViewPane {
@IEditorService private readonly editorService: IEditorService,
@IContextViewService private readonly contextViewService: IContextViewService,
@IConfigurationService configurationService: IConfigurationService,
@IViewDescriptorService viewDescriptorService: IViewDescriptorService,
@IContextKeyService contextKeyService: IContextKeyService,
) {
super({ ...(options as IViewPaneOptions), ariaHeaderLabel: nls.localize('breakpointsSection', "Breakpoints Section") }, keybindingService, contextMenuService, configurationService, contextKeyService, instantiationService);
super({ ...(options as IViewPaneOptions), ariaHeaderLabel: nls.localize('breakpointsSection', "Breakpoints Section") }, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService);

this.minimumBodySize = this.maximumBodySize = getExpandedBodySize(this.debugService.getModel());
this._register(this.debugService.getModel().onDidChangeBreakpoints(() => this.onBreakpointsChange()));
Expand Down
4 changes: 3 additions & 1 deletion src/vs/workbench/contrib/debug/browser/callStackView.ts
Expand Up @@ -35,6 +35,7 @@ import { STOP_ID, STOP_LABEL, DISCONNECT_ID, DISCONNECT_LABEL, RESTART_SESSION_I
import { ICommandService } from 'vs/platform/commands/common/commands';
import { CollapseAction } from 'vs/workbench/browser/viewlet';
import { SIDE_BAR_BACKGROUND } from 'vs/workbench/common/theme';
import { IViewDescriptorService } from 'vs/workbench/common/views';

const $ = dom.$;

Expand Down Expand Up @@ -92,12 +93,13 @@ export class CallStackView extends ViewPane {
@IDebugService private readonly debugService: IDebugService,
@IKeybindingService keybindingService: IKeybindingService,
@IInstantiationService instantiationService: IInstantiationService,
@IViewDescriptorService viewDescriptorService: IViewDescriptorService,
@IEditorService private readonly editorService: IEditorService,
@IConfigurationService configurationService: IConfigurationService,
@IMenuService menuService: IMenuService,
@IContextKeyService readonly contextKeyService: IContextKeyService,
) {
super({ ...(options as IViewPaneOptions), ariaHeaderLabel: nls.localize('callstackSection', "Call Stack Section") }, keybindingService, contextMenuService, configurationService, contextKeyService, instantiationService);
super({ ...(options as IViewPaneOptions), ariaHeaderLabel: nls.localize('callstackSection', "Call Stack Section") }, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService);
this.callStackItemType = CONTEXT_CALLSTACK_ITEM_TYPE.bindTo(contextKeyService);

this.contributedContextMenu = menuService.createMenu(MenuId.DebugCallStackContext, contextKeyService);
Expand Down
4 changes: 3 additions & 1 deletion src/vs/workbench/contrib/debug/browser/loadedScriptsView.ts
Expand Up @@ -37,6 +37,7 @@ import { ILabelService } from 'vs/platform/label/common/label';
import { SIDE_BAR_BACKGROUND } from 'vs/workbench/common/theme';
import type { ICompressedTreeNode } from 'vs/base/browser/ui/tree/compressedObjectTreeModel';
import type { ICompressibleTreeRenderer } from 'vs/base/browser/ui/tree/objectTree';
import { IViewDescriptorService } from 'vs/workbench/common/views';

const NEW_STYLE_COMPRESS = true;

Expand Down Expand Up @@ -415,6 +416,7 @@ export class LoadedScriptsView extends ViewPane {
@IContextMenuService contextMenuService: IContextMenuService,
@IKeybindingService keybindingService: IKeybindingService,
@IInstantiationService instantiationService: IInstantiationService,
@IViewDescriptorService viewDescriptorService: IViewDescriptorService,
@IConfigurationService configurationService: IConfigurationService,
@IEditorService private readonly editorService: IEditorService,
@IContextKeyService readonly contextKeyService: IContextKeyService,
Expand All @@ -423,7 +425,7 @@ export class LoadedScriptsView extends ViewPane {
@IDebugService private readonly debugService: IDebugService,
@ILabelService private readonly labelService: ILabelService
) {
super({ ...(options as IViewPaneOptions), ariaHeaderLabel: nls.localize('loadedScriptsSection', "Loaded Scripts Section") }, keybindingService, contextMenuService, configurationService, contextKeyService, instantiationService);
super({ ...(options as IViewPaneOptions), ariaHeaderLabel: nls.localize('loadedScriptsSection', "Loaded Scripts Section") }, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService);
this.loadedScriptsItemType = CONTEXT_LOADED_SCRIPTS_ITEM_TYPE.bindTo(contextKeyService);
}

Expand Down
5 changes: 3 additions & 2 deletions src/vs/workbench/contrib/debug/browser/repl.ts
Expand Up @@ -55,7 +55,7 @@ import { ReplDelegate, ReplVariablesRenderer, ReplSimpleElementsRenderer, ReplEv
import { localize } from 'vs/nls';
import { ViewPane, IViewPaneOptions } from 'vs/workbench/browser/parts/views/viewPaneContainer';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { IViewsService } from 'vs/workbench/common/views';
import { IViewsService, IViewDescriptorService } from 'vs/workbench/common/views';

const $ = dom.$;

Expand Down Expand Up @@ -109,14 +109,15 @@ export class Repl extends ViewPane implements IPrivateReplService, IHistoryNavig
@IModelService private readonly modelService: IModelService,
@IContextKeyService private readonly contextKeyService: IContextKeyService,
@ICodeEditorService codeEditorService: ICodeEditorService,
@IViewDescriptorService viewDescriptorService: IViewDescriptorService,
@IContextMenuService contextMenuService: IContextMenuService,
@IConfigurationService configurationService: IConfigurationService,
@ITextResourcePropertiesService private readonly textResourcePropertiesService: ITextResourcePropertiesService,
@IClipboardService private readonly clipboardService: IClipboardService,
@IEditorService private readonly editorService: IEditorService,
@IKeybindingService keybindingService: IKeybindingService
) {
super({ ...(options as IViewPaneOptions), id: REPL_VIEW_ID, ariaHeaderLabel: localize('debugConsole', "Debug Console") }, keybindingService, contextMenuService, configurationService, contextKeyService, instantiationService);
super({ ...(options as IViewPaneOptions), id: REPL_VIEW_ID, ariaHeaderLabel: localize('debugConsole', "Debug Console") }, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService);

this.history = new HistoryNavigator(JSON.parse(this.storageService.get(HISTORY_STORAGE_KEY, StorageScope.WORKSPACE, '[]')), 50);
codeEditorService.registerDecorationType(DECORATION_KEY, {});
Expand Down