未验证 提交 a86ff6a4 编写于 作者: S Sandeep Somavarapu 提交者: GitHub

Merge pull request #70224 from Microsoft/sandy081/adoptSearchViewlet

Adopt search viewlet to align with ViewsViewlet
......@@ -32,7 +32,7 @@ import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
import { IListService, WorkbenchListFocusContextKey, WorkbenchObjectTree } from 'vs/platform/list/browser/listService';
import { IQuickOpenService } from 'vs/platform/quickOpen/common/quickOpen';
import { Registry } from 'vs/platform/registry/common/platform';
import { ISearchConfigurationProperties, VIEW_ID, ISearchConfiguration } from 'vs/workbench/services/search/common/search';
import { ISearchConfigurationProperties, ISearchConfiguration, VIEWLET_ID, PANEL_ID, VIEW_ID, VIEW_CONTAINER } from 'vs/workbench/services/search/common/search';
import { defaultQuickOpenContextKey } from 'vs/workbench/browser/parts/quickopen/quickopen';
import { Extensions as QuickOpenExtensions, IQuickOpenRegistry, QuickOpenHandlerDescriptor } from 'vs/workbench/browser/quickopen';
import { Extensions as ActionExtensions, IWorkbenchActionRegistry } from 'vs/workbench/common/actions';
......@@ -53,8 +53,11 @@ import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
import { PanelRegistry, Extensions as PanelExtensions, PanelDescriptor } from 'vs/workbench/browser/panel';
import { ViewletDescriptor, ViewletRegistry, Extensions as ViewletExtensions } from 'vs/workbench/browser/viewlet';
import { SearchView } from 'vs/workbench/contrib/search/browser/searchView';
import { ISearchHistoryService, SearchHistoryService } from 'vs/workbench/contrib/search/common/searchHistoryService';
import { SearchViewlet } from 'vs/workbench/contrib/search/browser/searchViewlet';
import { SearchPanel } from 'vs/workbench/contrib/search/browser/searchPanel';
import { IViewsRegistry, Extensions as ViewExtensions } from 'vs/workbench/common/views';
import { SearchView } from 'vs/workbench/contrib/search/browser/searchView';
registerSingleton(ISearchWorkbenchService, SearchWorkbenchService, true);
registerSingleton(ISearchHistoryService, SearchHistoryService, true);
......@@ -466,6 +469,14 @@ class ShowAllSymbolsAction extends Action {
}
}
Registry.as<ViewletRegistry>(ViewletExtensions.Viewlets).registerViewlet(new ViewletDescriptor(
SearchViewlet,
VIEWLET_ID,
nls.localize('name', "Search"),
'search',
1
));
class RegisterSearchViewContribution implements IWorkbenchContribution {
constructor(
......@@ -473,31 +484,26 @@ class RegisterSearchViewContribution implements IWorkbenchContribution {
@IPanelService panelService: IPanelService,
@IConfigurationService configurationService: IConfigurationService
) {
const viewsRegistry = Registry.as<IViewsRegistry>(ViewExtensions.ViewsRegistry);
const updateSearchViewLocation = (open: boolean) => {
const config = configurationService.getValue<ISearchConfiguration>();
if (config.search.location === 'panel') {
Registry.as<ViewletRegistry>(ViewletExtensions.Viewlets).deregisterViewlet(VIEW_ID);
viewsRegistry.deregisterViews(viewsRegistry.getViews(VIEW_CONTAINER), VIEW_CONTAINER);
Registry.as<PanelRegistry>(PanelExtensions.Panels).registerPanel(new PanelDescriptor(
SearchView,
VIEW_ID,
SearchPanel,
PANEL_ID,
nls.localize('name', "Search"),
'search',
10
));
if (open) {
panelService.openPanel(VIEW_ID);
panelService.openPanel(PANEL_ID);
}
} else {
Registry.as<PanelRegistry>(PanelExtensions.Panels).deregisterPanel(VIEW_ID);
Registry.as<ViewletRegistry>(ViewletExtensions.Viewlets).registerViewlet(new ViewletDescriptor(
SearchView,
VIEW_ID,
nls.localize('name', "Search"),
'search',
1
));
Registry.as<PanelRegistry>(PanelExtensions.Panels).deregisterPanel(PANEL_ID);
viewsRegistry.registerViews([{ id: VIEW_ID, name: nls.localize('search', "Search"), ctorDescriptor: { ctor: SearchView }, canToggleVisibility: false }], VIEW_CONTAINER);
if (open) {
viewletService.openViewlet(VIEW_ID);
viewletService.openViewlet(VIEWLET_ID);
}
}
};
......@@ -517,7 +523,7 @@ const registry = Registry.as<IWorkbenchActionRegistry>(ActionExtensions.Workbenc
// Show Search and Find in Files are redundant, but we can't break keybindings by removing one. So it's the same action, same keybinding, registered to different IDs.
// Show Search 'when' is redundant but if the two conflict with exactly the same keybinding and 'when' clause, then they can show up as "unbound" - #51780
registry.registerWorkbenchAction(new SyncActionDescriptor(OpenSearchViewletAction, VIEW_ID, OpenSearchViewletAction.LABEL, { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_F }, Constants.SearchViewVisibleKey.toNegated()), 'View: Show Search', nls.localize('view', "View"));
registry.registerWorkbenchAction(new SyncActionDescriptor(OpenSearchViewletAction, VIEWLET_ID, OpenSearchViewletAction.LABEL, { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_F }, Constants.SearchViewVisibleKey.toNegated()), 'View: Show Search', nls.localize('view', "View"));
registry.registerWorkbenchAction(new SyncActionDescriptor(FindInFilesAction, Constants.FindInFilesActionId, nls.localize('findInFiles', "Find in Files"), { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_F }), 'Find in Files', category);
MenuRegistry.appendMenuItem(MenuId.MenubarEditMenu, {
group: '4_find_global',
......@@ -747,7 +753,7 @@ registerLanguageCommand('_executeWorkspaceSymbolProvider', function (accessor, a
MenuRegistry.appendMenuItem(MenuId.MenubarViewMenu, {
group: '3_views',
command: {
id: VIEW_ID,
id: VIEWLET_ID,
title: nls.localize({ key: 'miViewSearch', comment: ['&& denotes a mnemonic'] }, "&&Search")
},
order: 2
......
......@@ -27,9 +27,11 @@ import { BaseFolderMatch, FileMatch, FileMatchOrMatch, FolderMatch, Match, Rende
import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
import { ISearchConfiguration, VIEW_ID } from 'vs/workbench/services/search/common/search';
import { ISearchConfiguration, VIEWLET_ID, PANEL_ID } from 'vs/workbench/services/search/common/search';
import { ISearchHistoryService } from 'vs/workbench/contrib/search/common/searchHistoryService';
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
import { SearchViewlet } from 'vs/workbench/contrib/search/browser/searchViewlet';
import { SearchPanel } from 'vs/workbench/contrib/search/browser/searchPanel';
export function isSearchViewFocused(viewletService: IViewletService, panelService: IPanelService): boolean {
const searchView = getSearchView(viewletService, panelService);
......@@ -51,22 +53,22 @@ export function appendKeyBindingLabel(label: string, inputKeyBinding: number | R
}
export function openSearchView(viewletService: IViewletService, panelService: IPanelService, focus?: boolean): Promise<SearchView> {
if (viewletService.getViewlets().filter(v => v.id === VIEW_ID).length) {
return viewletService.openViewlet(VIEW_ID, focus).then(viewlet => <SearchView>viewlet);
if (viewletService.getViewlets().filter(v => v.id === VIEWLET_ID).length) {
return viewletService.openViewlet(VIEWLET_ID, focus).then(viewlet => (viewlet as SearchViewlet).getSearchView());
}
return Promise.resolve(panelService.openPanel(VIEW_ID, focus) as SearchView);
return Promise.resolve((panelService.openPanel(PANEL_ID, focus) as SearchPanel).getSearchView());
}
export function getSearchView(viewletService: IViewletService, panelService: IPanelService): SearchView | null {
const activeViewlet = viewletService.getActiveViewlet();
if (activeViewlet && activeViewlet.getId() === VIEW_ID) {
return <SearchView>activeViewlet;
if (activeViewlet && activeViewlet.getId() === VIEWLET_ID) {
return (activeViewlet as SearchViewlet).getSearchView();
}
const activePanel = panelService.getActivePanel();
if (activePanel && activePanel.getId() === VIEW_ID) {
return <SearchView>activePanel;
if (activePanel && activePanel.getId() === PANEL_ID) {
return (activePanel as SearchPanel).getSearchView();
}
return null;
......
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IStorageService } from 'vs/platform/storage/common/storage';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { PANEL_ID } from 'vs/workbench/services/search/common/search';
import { SearchView } from 'vs/workbench/contrib/search/browser/searchView';
import { Panel } from 'vs/workbench/browser/panel';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { localize } from 'vs/nls';
import * as dom from 'vs/base/browser/dom';
import { IAction } from 'vs/base/common/actions';
export class SearchPanel extends Panel {
private readonly searchView: SearchView;
constructor(
@ITelemetryService telemetryService: ITelemetryService,
@IThemeService themeService: IThemeService,
@IStorageService storageService: IStorageService,
@IInstantiationService instantiationService: IInstantiationService,
) {
super(PANEL_ID, telemetryService, themeService, storageService);
this.searchView = this._register(instantiationService.createInstance(SearchView, { id: PANEL_ID, title: localize('search', "Search") }));
this._register(this.searchView.onDidChangeTitleArea(() => this.updateTitleArea()));
this._register(this.onDidChangeVisibility(visible => this.searchView.setVisible(visible)));
}
create(parent: HTMLElement): void {
dom.addClass(parent, 'monaco-panel-view');
this.searchView.render();
dom.append(parent, this.searchView.element);
this.searchView.setExpanded(true);
this.searchView.headerVisible = false;
}
public getTitle(): string {
return this.searchView.title;
}
public layout(dimension: dom.Dimension): void {
this.searchView.width = dimension.width;
this.searchView.layout(dimension.height);
}
public focus(): void {
this.searchView.focus();
}
getActions(): IAction[] {
return this.searchView.getActions();
}
getSecondaryActions(): IAction[] {
return this.searchView.getSecondaryActions();
}
saveState(): void {
this.searchView.saveState();
super.saveState();
}
getSearchView(): SearchView | null {
return this.searchView;
}
}
\ No newline at end of file
......@@ -36,17 +36,12 @@ import { INotificationService, Severity } from 'vs/platform/notification/common/
import { IProgressService } from 'vs/platform/progress/common/progress';
import { IPatternInfo, ISearchComplete, ISearchConfiguration, ISearchConfigurationProperties, ITextQuery, SearchErrorCode, VIEW_ID } from 'vs/workbench/services/search/common/search';
import { ISearchHistoryService, ISearchHistoryValues } from 'vs/workbench/contrib/search/common/searchHistoryService';
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { diffInserted, diffInsertedOutline, diffRemoved, diffRemovedOutline, editorFindMatchHighlight, editorFindMatchHighlightBorder, listActiveSelectionForeground } from 'vs/platform/theme/common/colorRegistry';
import { ICssStyleCollector, ITheme, IThemeService, registerThemingParticipant } from 'vs/platform/theme/common/themeService';
import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/common/workspace';
import { OpenFileFolderAction, OpenFolderAction } from 'vs/workbench/browser/actions/workspaceActions';
import { ResourceLabels } from 'vs/workbench/browser/labels';
import { Viewlet } from 'vs/workbench/browser/viewlet';
import { ResourceLabels, IResourceLabelsContainer } from 'vs/workbench/browser/labels';
import { IEditor } from 'vs/workbench/common/editor';
import { IPanel } from 'vs/workbench/common/panel';
import { IViewlet } from 'vs/workbench/common/viewlet';
import { ExcludePatternInputWidget, PatternInputWidget } from 'vs/workbench/contrib/search/browser/patternInputWidget';
import { CancelSearchAction, ClearSearchResultsAction, CollapseDeepestExpandedLevelAction, RefreshAction } from 'vs/workbench/contrib/search/browser/searchActions';
import { FileMatchRenderer, FolderMatchRenderer, MatchRenderer, SearchAccessibilityProvider, SearchDelegate, SearchDND } from 'vs/workbench/contrib/search/browser/searchResultsView';
......@@ -58,15 +53,18 @@ import { getOutOfWorkspaceEditorResources } from 'vs/workbench/contrib/search/co
import { FileMatch, FileMatchOrMatch, FolderMatch, IChangeEvent, ISearchWorkbenchService, Match, RenderableMatch, searchMatchComparer, SearchModel, SearchResult, BaseFolderMatch } from 'vs/workbench/contrib/search/common/searchModel';
import { ACTIVE_GROUP, IEditorService, SIDE_GROUP } from 'vs/workbench/services/editor/common/editorService';
import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService';
import { IPreferencesService, ISettingsEditorOptions } from 'vs/workbench/services/preferences/common/preferences';
import { IUntitledEditorService } from 'vs/workbench/services/untitled/common/untitledEditorService';
import { relativePath } from 'vs/base/common/resources';
import { IAccessibilityService, AccessibilitySupport } from 'vs/platform/accessibility/common/accessibility';
import { ViewletPanel, IViewletPanelOptions } from 'vs/workbench/browser/parts/views/panelViewlet';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { Memento } from 'vs/workbench/common/memento';
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
const $ = dom.$;
export class SearchView extends Viewlet implements IViewlet, IPanel {
export class SearchView extends ViewletPanel {
private static readonly MAX_TEXT_RESULTS = 10000;
......@@ -76,8 +74,10 @@ export class SearchView extends Viewlet implements IViewlet, IPanel {
private isDisposed: boolean;
private container: HTMLElement;
private queryBuilder: QueryBuilder;
private viewModel: SearchModel;
private memento: Memento;
private viewletVisible: IContextKey<boolean>;
private viewletFocused: IContextKey<boolean>;
......@@ -126,14 +126,12 @@ export class SearchView extends Viewlet implements IViewlet, IPanel {
private currentSearchQ = Promise.resolve();
constructor(
@IWorkbenchLayoutService layoutService: IWorkbenchLayoutService,
@ITelemetryService telemetryService: ITelemetryService,
options: IViewletPanelOptions,
@IFileService private readonly fileService: IFileService,
@IEditorService private readonly editorService: IEditorService,
@IProgressService private readonly progressService: IProgressService,
@INotificationService private readonly notificationService: INotificationService,
@IDialogService private readonly dialogService: IDialogService,
@IStorageService storageService: IStorageService,
@IContextViewService private readonly contextViewService: IContextViewService,
@IInstantiationService private readonly instantiationService: IInstantiationService,
@IConfigurationService configurationService: IConfigurationService,
......@@ -146,11 +144,13 @@ export class SearchView extends Viewlet implements IViewlet, IPanel {
@IThemeService protected themeService: IThemeService,
@ISearchHistoryService private readonly searchHistoryService: ISearchHistoryService,
@IEditorGroupsService private readonly editorGroupsService: IEditorGroupsService,
@IContextMenuService private readonly contextMenuService: IContextMenuService,
@IContextMenuService contextMenuService: IContextMenuService,
@IMenuService private readonly menuService: IMenuService,
@IAccessibilityService private readonly accessibilityService: IAccessibilityService
@IAccessibilityService private readonly accessibilityService: IAccessibilityService,
@IKeybindingService keybindingService: IKeybindingService,
@IStorageService storageService: IStorageService,
) {
super(VIEW_ID, configurationService, layoutService, telemetryService, themeService, storageService);
super({ ...(options as IViewletPanelOptions), id: VIEW_ID, ariaHeaderLabel: nls.localize('searchView', "Search") }, keybindingService, contextMenuService, configurationService);
this.viewletVisible = Constants.SearchViewVisibleKey.bindTo(contextKeyService);
this.viewletFocused = Constants.SearchViewFocusedKey.bindTo(contextKeyService);
......@@ -166,8 +166,9 @@ export class SearchView extends Viewlet implements IViewlet, IPanel {
this.hasSearchResultsKey = Constants.HasSearchResults.bindTo(this.contextKeyService);
this.queryBuilder = this.instantiationService.createInstance(QueryBuilder);
this.viewletState = this.getMemento(StorageScope.WORKSPACE);
this.globalMemento = this.getMemento(StorageScope.GLOBAL);
this.memento = new Memento(this.id, storageService);
this.viewletState = this.memento.getMemento(StorageScope.WORKSPACE);
this.globalMemento = this.memento.getMemento(StorageScope.GLOBAL);
this._register(this.fileService.onFileChanges(e => this.onFilesChanged(e)));
this._register(this.untitledEditorService.onDidChangeDirty(e => this.onUntitledDidChangeDirty(e)));
......@@ -180,6 +181,16 @@ export class SearchView extends Viewlet implements IViewlet, IPanel {
this.delayedRefresh = this._register(new Delayer<void>(250));
this.actions = [
this._register(this.instantiationService.createInstance(ClearSearchResultsAction, ClearSearchResultsAction.ID, ClearSearchResultsAction.LABEL)),
this._register(this.instantiationService.createInstance(CollapseDeepestExpandedLevelAction, CollapseDeepestExpandedLevelAction.ID, CollapseDeepestExpandedLevelAction.LABEL))
];
this.refreshAction = this._register(this.instantiationService.createInstance(RefreshAction, RefreshAction.ID, RefreshAction.LABEL));
this.cancelAction = this._register(this.instantiationService.createInstance(CancelSearchAction, CancelSearchAction.ID, CancelSearchAction.LABEL));
}
getContainer(): HTMLElement {
return this.container;
}
get searchResult(): SearchResult {
......@@ -192,13 +203,11 @@ export class SearchView extends Viewlet implements IViewlet, IPanel {
}
}
create(parent: HTMLElement): void {
super.create(parent);
renderBody(parent: HTMLElement): void {
this.viewModel = this._register(this.searchWorkbenchService.searchModel);
dom.addClass(parent, 'search-view');
this.container = dom.append(parent, dom.$('.search-view'));
this.searchWidgetsContainerElement = dom.append(parent, $('.search-widgets-container'));
this.searchWidgetsContainerElement = dom.append(this.container, $('.search-widgets-container'));
this.createSearchWidget(this.searchWidgetsContainerElement);
const history = this.searchHistoryService.load();
......@@ -275,19 +284,12 @@ export class SearchView extends Viewlet implements IViewlet, IPanel {
this.inputPatternExcludes.onCancel(() => this.viewModel.cancelSearch()); // Cancel search without focusing the search widget
this.trackInputBox(this.inputPatternExcludes.inputFocusTracker, this.inputPatternExclusionsFocused);
this.messagesElement = dom.append(parent, $('.messages'));
this.messagesElement = dom.append(this.container, $('.messages'));
if (this.contextService.getWorkbenchState() === WorkbenchState.EMPTY) {
this.showSearchWithoutFolderMessage();
}
this.createSearchResultsView(parent);
this.actions = [
this._register(this.instantiationService.createInstance(ClearSearchResultsAction, ClearSearchResultsAction.ID, ClearSearchResultsAction.LABEL)),
this._register(this.instantiationService.createInstance(CollapseDeepestExpandedLevelAction, CollapseDeepestExpandedLevelAction.ID, CollapseDeepestExpandedLevelAction.LABEL))
];
this.refreshAction = this._register(this.instantiationService.createInstance(RefreshAction, RefreshAction.ID, RefreshAction.LABEL));
this.cancelAction = this._register(this.instantiationService.createInstance(CancelSearchAction, CancelSearchAction.ID, CancelSearchAction.LABEL));
this.createSearchResultsView(this.container);
if (filePatterns !== '' || patternExclusions !== '' || patternIncludes !== '' || queryDetailsExpanded !== '' || !useExcludesAndIgnoreFiles) {
this.toggleQueryDetails(true, true, true);
......@@ -301,7 +303,7 @@ export class SearchView extends Viewlet implements IViewlet, IPanel {
this._register(this.onDidFocus(() => this.viewletFocused.set(true)));
this._register(this.onDidBlur(() => this.viewletFocused.set(false)));
this._register(this.onDidChangeVisibility(visible => this.onVisibilityChanged(visible)));
this._register(this.onDidChangeBodyVisibility(visible => this.onVisibilityChanged(visible)));
}
private onVisibilityChanged(visible: boolean): void {
......@@ -340,12 +342,13 @@ export class SearchView extends Viewlet implements IViewlet, IPanel {
return this.inputPatternExcludes;
}
private updateActions(): void {
protected updateActions(): void {
for (const action of this.actions) {
action.update();
this.refreshAction.update();
this.cancelAction.update();
}
super.updateActions();
}
private isScreenReaderOptimized() {
......@@ -622,7 +625,7 @@ export class SearchView extends Viewlet implements IViewlet, IPanel {
}
};
this.treeLabels = this._register(this.instantiationService.createInstance(ResourceLabels, this));
this.treeLabels = this._register(this.instantiationService.createInstance(ResourceLabels, { onDidChangeVisibility: this.onDidChangeBodyVisibility } as IResourceLabelsContainer));
this.tree = this._register(<WorkbenchObjectTree<RenderableMatch, any>>this.instantiationService.createInstance(WorkbenchObjectTree,
this.resultsElement,
delegate,
......@@ -907,8 +910,8 @@ export class SearchView extends Viewlet implements IViewlet, IPanel {
this.tree.layout(searchResultContainerSize, this.size.width);
}
layout(dimension: dom.Dimension): void {
this.size = dimension;
protected layoutBody(height: number, width: number): void {
this.size = new dom.Dimension(width, height);
this.reLayout();
}
......@@ -1067,7 +1070,7 @@ export class SearchView extends Viewlet implements IViewlet, IPanel {
}
if (!skipLayout && this.size) {
this.layout(this.size);
this.layout(this.size.height);
}
}
......@@ -1235,7 +1238,6 @@ export class SearchView extends Viewlet implements IViewlet, IPanel {
setTimeout(() => {
if (this.searching) {
this.updateActions();
this.updateTitleArea();
}
}, 2000);
this.showEmptyStage();
......@@ -1261,7 +1263,6 @@ export class SearchView extends Viewlet implements IViewlet, IPanel {
this.searchSubmitted = true;
this.updateActions();
this.updateTitleArea();
const hasResults = !this.viewModel.searchResult.isEmpty();
if (completed && completed.limitHit) {
......@@ -1341,7 +1342,6 @@ export class SearchView extends Viewlet implements IViewlet, IPanel {
} else {
this.searching = false;
this.updateActions();
this.updateTitleArea();
progressRunner.done();
this.searchWidget.searchInput.showMessage({ content: e.message, type: MessageType.ERROR });
this.viewModel.searchResult.clear();
......@@ -1612,7 +1612,7 @@ export class SearchView extends Viewlet implements IViewlet, IPanel {
this.inputPatternIncludes.clearHistory();
}
protected saveState(): void {
public saveState(): void {
const isRegex = this.searchWidget.searchInput.getRegex();
const isWholeWords = this.searchWidget.searchInput.getWholeWords();
const isCaseSensitive = this.searchWidget.searchInput.getCaseSensitive();
......@@ -1660,9 +1660,21 @@ export class SearchView extends Viewlet implements IViewlet, IPanel {
super.saveState();
}
private _toDispose: IDisposable[] = [];
protected _register<T extends IDisposable>(t: T): T {
if (this.isDisposed) {
console.warn('Registering disposable on object that has already been disposed.');
t.dispose();
} else {
this._toDispose.push(t);
}
return t;
}
dispose(): void {
this.isDisposed = true;
this.saveState();
this._toDispose = dispose(this._toDispose);
super.dispose();
}
}
......
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { ViewContainerViewlet } from 'vs/workbench/browser/parts/views/viewsViewlet';
import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { IStorageService } from 'vs/platform/storage/common/storage';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
import { VIEWLET_ID, VIEW_ID } from 'vs/workbench/services/search/common/search';
import { SearchView } from 'vs/workbench/contrib/search/browser/searchView';
import { Registry } from 'vs/platform/registry/common/platform';
import { ViewletRegistry, Extensions } from 'vs/workbench/browser/viewlet';
export class SearchViewlet extends ViewContainerViewlet {
constructor(
@IWorkbenchLayoutService layoutService: IWorkbenchLayoutService,
@ITelemetryService telemetryService: ITelemetryService,
@IWorkspaceContextService protected contextService: IWorkspaceContextService,
@IStorageService protected storageService: IStorageService,
@IConfigurationService configurationService: IConfigurationService,
@IInstantiationService protected instantiationService: IInstantiationService,
@IThemeService themeService: IThemeService,
@IContextMenuService contextMenuService: IContextMenuService,
@IExtensionService extensionService: IExtensionService
) {
super(VIEWLET_ID, `${VIEWLET_ID}.state`, true, configurationService, layoutService, telemetryService, storageService, instantiationService, themeService, contextMenuService, extensionService, contextService);
}
getTitle(): string {
return Registry.as<ViewletRegistry>(Extensions.Viewlets).getViewlet(this.getId()).name;
}
getSearchView(): SearchView | null {
const view = super.getView(VIEW_ID);
return view ? view as SearchView : null;
}
}
\ No newline at end of file
......@@ -15,8 +15,16 @@ import { IFilesConfiguration } from 'vs/platform/files/common/files';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { ITelemetryData } from 'vs/platform/telemetry/common/telemetry';
import { Event } from 'vs/base/common/event';
import { ViewContainer, IViewContainersRegistry, Extensions as ViewContainerExtensions } from 'vs/workbench/common/views';
import { Registry } from 'vs/platform/registry/common/platform';
export const VIEWLET_ID = 'workbench.view.search';
export const PANEL_ID = 'workbench.view.search';
export const VIEW_ID = 'workbench.view.search';
/**
* Search viewlet container.
*/
export const VIEW_CONTAINER: ViewContainer = Registry.as<IViewContainersRegistry>(ViewContainerExtensions.ViewContainersRegistry).registerViewContainer(VIEWLET_ID, true);
export const ISearchService = createDecorator<ISearchService>('searchService');
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册