Skip to content

Commit

Permalink
use improved openView api, nuke singleton, microsoft#49922
Browse files Browse the repository at this point in the history
  • Loading branch information
jrieken committed Jun 8, 2018
1 parent 83cec01 commit 9c3af12
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import { MenuRegistry } from 'vs/platform/actions/common/actions';
import { VIEW_CONTAINER } from 'vs/workbench/parts/files/common/files';
import { Registry } from 'vs/platform/registry/common/platform';
import { IConfigurationRegistry, Extensions as ConfigurationExtensions } from 'vs/platform/configuration/common/configurationRegistry';
import { OutlineConfigKeys } from 'vs/workbench/parts/outline/electron-browser/outline';
import { OutlineConfigKeys, OutlineViewId } from 'vs/workbench/parts/outline/electron-browser/outline';

const _outlineDesc = <IViewDescriptor>{
id: 'code.outline',
id: OutlineViewId,
name: localize('name', "Outline"),
ctor: OutlinePanel,
container: VIEW_CONTAINER,
Expand All @@ -30,7 +30,7 @@ ViewsRegistry.registerViews([_outlineDesc]);

CommandsRegistry.registerCommand('outline.focus', accessor => {
let viewsService = accessor.get(IViewsService);
return viewsService.openView(_outlineDesc.id, true);
return viewsService.openView(OutlineViewId, true);
});

MenuRegistry.addCommand({
Expand Down
2 changes: 2 additions & 0 deletions src/vs/workbench/parts/outline/electron-browser/outline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

import { RawContextKey } from 'vs/platform/contextkey/common/contextkey';

export const OutlineViewId = 'outline';

export const OutlineViewFiltered = new RawContextKey('outlineFiltered', false);
export const OutlineViewFocused = new RawContextKey('outlineFocused', false);

Expand Down
15 changes: 7 additions & 8 deletions src/vs/workbench/parts/outline/electron-browser/outlinePanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,10 @@ import { IViewletViewOptions } from 'vs/workbench/browser/parts/views/viewsViewl
import { CollapseAction } from 'vs/workbench/browser/viewlet';
import { ACTIVE_GROUP, IEditorService, SIDE_GROUP } from 'vs/workbench/services/editor/common/editorService';
import { KeyboardMapperFactory } from 'vs/workbench/services/keybinding/electron-browser/keybindingService';
import { OutlineConfigKeys, OutlineViewFiltered, OutlineViewFocused } from './outline';
import { OutlineConfigKeys, OutlineViewFiltered, OutlineViewFocused, OutlineViewId } from './outline';
import { OutlineElement, OutlineModel, TreeElement } from './outlineModel';
import { OutlineController, OutlineDataSource, OutlineItemComparator, OutlineItemCompareType, OutlineItemFilter, OutlineRenderer, OutlineTreeState } from './outlineTree';
import { IViewsService } from 'vs/workbench/common/views';

class RequestState {

Expand Down Expand Up @@ -208,8 +209,6 @@ class OutlineState {

export class OutlinePanel extends ViewletPanel {

static InstanceHack: OutlinePanel;

private _disposables = new Array<IDisposable>();

private _editorDisposables = new Array<IDisposable>();
Expand Down Expand Up @@ -244,7 +243,6 @@ export class OutlinePanel extends ViewletPanel {
@IContextMenuService contextMenuService: IContextMenuService,
) {
super(options, keybindingService, contextMenuService, configurationService);
OutlinePanel.InstanceHack = this;
this._outlineViewState.restore(this._storageService);
this._contextKeyFocused = OutlineViewFocused.bindTo(contextKeyService);
this._contextKeyFiltered = OutlineViewFiltered.bindTo(contextKeyService);
Expand All @@ -253,7 +251,6 @@ export class OutlinePanel extends ViewletPanel {
}

dispose(): void {
OutlinePanel.InstanceHack = undefined;
dispose(this._disposables);
dispose(this._requestOracle);
super.dispose();
Expand Down Expand Up @@ -627,9 +624,11 @@ export class OutlinePanel extends ViewletPanel {
}
}

function goUpOrDownToHighligthedElement(accessor: ServicesAccessor, prev: boolean) {
if (OutlinePanel.InstanceHack) {
OutlinePanel.InstanceHack.focusHighlightedElement(prev);
async function goUpOrDownToHighligthedElement(accessor: ServicesAccessor, prev: boolean) {
const viewsService = accessor.get(IViewsService);
const view = await viewsService.openView(OutlineViewId);
if (view instanceof OutlinePanel) {
view.focusHighlightedElement(prev);
}
}

Expand Down

0 comments on commit 9c3af12

Please sign in to comment.