Skip to content

Commit ed5bc91

Browse files
committed
Debt: Use viewlet view settings
1 parent 3ef002b commit ed5bc91

3 files changed

Lines changed: 17 additions & 14 deletions

File tree

src/vs/workbench/parts/files/browser/explorerViewlet.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@ import { IActionRunner } from 'vs/base/common/actions';
1010
import { TPromise } from 'vs/base/common/winjs.base';
1111
import * as DOM from 'vs/base/browser/dom';
1212
import { Builder } from 'vs/base/browser/builder';
13-
import { Scope } from 'vs/workbench/common/memento';
1413
import { VIEWLET_ID, ExplorerViewletVisibleContext, IFilesConfiguration } from 'vs/workbench/parts/files/common/files';
15-
import { ComposedViewsViewlet, IViewletView } from 'vs/workbench/parts/views/browser/views';
14+
import { ComposedViewsViewlet, IViewletView, IViewletViewOptions } from 'vs/workbench/parts/views/browser/views';
1615
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
1716
import { ActionRunner, FileViewletState } from 'vs/workbench/parts/files/browser/views/explorerViewer';
1817
import { ExplorerView, IExplorerViewOptions } from 'vs/workbench/parts/files/browser/views/explorerView';
@@ -30,13 +29,12 @@ import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/edi
3029
import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService';
3130
import { IContextKeyService, IContextKey } from 'vs/platform/contextkey/common/contextkey';
3231
import { IThemeService } from 'vs/platform/theme/common/themeService';
33-
import { ViewsRegistry, ViewLocation, IViewDescriptor, IViewOptions } from 'vs/workbench/parts/views/browser/viewsRegistry';
32+
import { ViewsRegistry, ViewLocation, IViewDescriptor } from 'vs/workbench/parts/views/browser/viewsRegistry';
3433

3534
export class ExplorerViewlet extends ComposedViewsViewlet {
3635

3736
private static EXPLORER_VIEWS_STATE = 'workbench.explorer.views.state';
3837

39-
private viewletSettings: any;
4038
private viewletState: FileViewletState;
4139
private viewletVisibleContextKey: IContextKey<boolean>;
4240

@@ -54,7 +52,6 @@ export class ExplorerViewlet extends ComposedViewsViewlet {
5452
super(VIEWLET_ID, ViewLocation.Explorer, ExplorerViewlet.EXPLORER_VIEWS_STATE, telemetryService, storageService, instantiationService, themeService, contextService);
5553

5654
this.viewletState = new FileViewletState();
57-
this.viewletSettings = this.getMemento(storageService, Scope.WORKSPACE);
5855
this.viewletVisibleContextKey = ExplorerViewletVisibleContext.bindTo(contextKeyService);
5956

6057
this.registerViews();
@@ -127,7 +124,7 @@ export class ExplorerViewlet extends ComposedViewsViewlet {
127124
return !this.contextService.hasWorkspace() || (<IFilesConfiguration>this.configurationService.getConfiguration()).explorer.openEditors.visible !== 0;
128125
}
129126

130-
protected createView(viewDescriptor: IViewDescriptor, options: IViewOptions): IViewletView {
127+
protected createView(viewDescriptor: IViewDescriptor, options: IViewletViewOptions): IViewletView {
131128
if (viewDescriptor.id === ExplorerView.ID) {
132129
// Create a delegating editor service for the explorer to be able to delay the refresh in the opened
133130
// editors view above. This is a workaround for being able to double click on a file to make it pinned
@@ -167,7 +164,7 @@ export class ExplorerViewlet extends ComposedViewsViewlet {
167164
});
168165

169166
const explorerInstantiator = this.instantiationService.createChild(new ServiceCollection([IWorkbenchEditorService, delegatingEditorService]));
170-
return explorerInstantiator.createInstance(ExplorerView, viewDescriptor.id, <IExplorerViewOptions>{ ...options, settings: this.viewletSettings, viewletState: this.viewletState });
167+
return explorerInstantiator.createInstance(ExplorerView, viewDescriptor.id, <IExplorerViewOptions>{ ...options, viewletState: this.viewletState });
171168
}
172169
return super.createView(viewDescriptor, options);
173170
}

src/vs/workbench/parts/files/browser/views/explorerView.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import { DiffEditorInput } from 'vs/workbench/common/editor/diffEditorInput';
2525
import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService';
2626
import * as DOM from 'vs/base/browser/dom';
2727
import { CollapseAction } from 'vs/workbench/browser/viewlet';
28-
import { CollapsibleViewletView } from 'vs/workbench/parts/views/browser/views';
28+
import { CollapsibleViewletView, IViewletViewOptions } from 'vs/workbench/parts/views/browser/views';
2929
import { FileStat } from 'vs/workbench/parts/files/common/explorerViewModel';
3030
import { IListService } from 'vs/platform/list/browser/listService';
3131
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
@@ -43,10 +43,8 @@ import { IWorkbenchThemeService, IFileIconTheme } from 'vs/workbench/services/th
4343
import { isLinux } from 'vs/base/common/platform';
4444
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
4545
import { attachListStyler } from 'vs/platform/theme/common/styler';
46-
import { IViewOptions } from 'vs/workbench/parts/views/browser/viewsRegistry';
4746

48-
export interface IExplorerViewOptions extends IViewOptions {
49-
settings: any;
47+
export interface IExplorerViewOptions extends IViewletViewOptions {
5048
viewletState: FileViewletState;
5149
}
5250

@@ -104,7 +102,7 @@ export class ExplorerView extends CollapsibleViewletView {
104102
) {
105103
super(options.actionRunner, options.collapsed, nls.localize('explorerSection', "Files Explorer Section"), messageService, keybindingService, contextMenuService);
106104

107-
this.settings = options.settings;
105+
this.settings = options.viewletSettings;
108106
this.viewletState = options.viewletState;
109107
this.actionRunner = options.actionRunner;
110108
this.autoReveal = true;

src/vs/workbench/parts/views/browser/views.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { IThemable, attachHeaderViewStyler } from 'vs/platform/theme/common/styl
99
import * as errors from 'vs/base/common/errors';
1010
import * as DOM from 'vs/base/browser/dom';
1111
import { $, Dimension, Builder } from 'vs/base/browser/builder';
12+
import { Scope } from 'vs/workbench/common/memento';
1213
import { dispose, IDisposable } from 'vs/base/common/lifecycle';
1314
import { IAction, IActionRunner } from 'vs/base/common/actions';
1415
import { IActionItem, ActionsOrientation } from 'vs/base/browser/ui/actionbar/actionbar';
@@ -28,6 +29,10 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
2829
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
2930
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
3031

32+
export interface IViewletViewOptions extends IViewOptions {
33+
viewletSettings: any;
34+
}
35+
3136
export interface IViewletView extends IView, IThemable {
3237
id?: string;
3338
create(): TPromise<void>;
@@ -373,6 +378,7 @@ export class ComposedViewsViewlet extends Viewlet {
373378
private splitView: SplitView;
374379
private views: IViewletView[];
375380
private dimension: Dimension;
381+
private viewletSettings: any;
376382

377383
private readonly viewsStates: Map<string, IViewState>;
378384

@@ -389,6 +395,7 @@ export class ComposedViewsViewlet extends Viewlet {
389395
super(id, telemetryService, themeService);
390396

391397
this.views = [];
398+
this.viewletSettings = this.getMemento(storageService, Scope.WORKSPACE);
392399
this.viewsStates = this.loadViewsStates();
393400

394401
this._register(ViewsRegistry.onViewsRegistered(viewDescriptors => this.createViews(viewDescriptors.filter(viewDescriptor => ViewLocation.Explorer === viewDescriptor.location))));
@@ -444,7 +451,8 @@ export class ComposedViewsViewlet extends Viewlet {
444451
const view = this.createView(viewDescriptor, {
445452
name: viewDescriptor.name,
446453
actionRunner: this.getActionRunner(),
447-
collapsed: viewState ? viewState.collapsed : true
454+
collapsed: viewState ? viewState.collapsed : true,
455+
viewletSettings: this.viewletSettings
448456
});
449457
if (index !== -1) {
450458
this.views.splice(index, 0, view);
@@ -546,7 +554,7 @@ export class ComposedViewsViewlet extends Viewlet {
546554
}, new Map<string, IViewState>());
547555
}
548556

549-
protected createView(viewDescriptor: IViewDescriptor, options: IViewOptions): IViewletView {
557+
protected createView(viewDescriptor: IViewDescriptor, options: IViewletViewOptions): IViewletView {
550558
return this.instantiationService.createInstance(viewDescriptor.ctor, viewDescriptor.id, options);
551559
}
552560

0 commit comments

Comments
 (0)