提交 9e9501bf 编写于 作者: J Johannes Rieken

sync outline view state (filter mode, sort mode, follow cursor mode) across...

sync outline view state (filter mode, sort mode, follow cursor mode) across machines, https://github.com/microsoft/vscode/issues/93332
上级 3c7b3f4f
...@@ -51,6 +51,7 @@ import { IViewDescriptorService } from 'vs/workbench/common/views'; ...@@ -51,6 +51,7 @@ import { IViewDescriptorService } from 'vs/workbench/common/views';
import { IOpenerService } from 'vs/platform/opener/common/opener'; import { IOpenerService } from 'vs/platform/opener/common/opener';
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService'; import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IStorageKeysSyncRegistryService } from 'vs/platform/userDataSync/common/storageKeys';
class RequestState { class RequestState {
...@@ -176,6 +177,13 @@ class OutlineViewState { ...@@ -176,6 +177,13 @@ class OutlineViewState {
private readonly _onDidChange = new Emitter<{ followCursor?: boolean, sortBy?: boolean, filterOnType?: boolean }>(); private readonly _onDidChange = new Emitter<{ followCursor?: boolean, sortBy?: boolean, filterOnType?: boolean }>();
readonly onDidChange = this._onDidChange.event; readonly onDidChange = this._onDidChange.event;
constructor(
@IStorageService private readonly _storageService: IStorageService,
@IStorageKeysSyncRegistryService storageKeysSyncService: IStorageKeysSyncRegistryService
) {
storageKeysSyncService.registerStorageKey({ key: 'outline/state', version: 1 });
}
set followCursor(value: boolean) { set followCursor(value: boolean) {
if (value !== this._followCursor) { if (value !== this._followCursor) {
this._followCursor = value; this._followCursor = value;
...@@ -209,16 +217,16 @@ class OutlineViewState { ...@@ -209,16 +217,16 @@ class OutlineViewState {
return this._sortBy; return this._sortBy;
} }
persist(storageService: IStorageService): void { persist(): void {
storageService.store('outline/state', JSON.stringify({ this._storageService.store('outline/state', JSON.stringify({
followCursor: this.followCursor, followCursor: this.followCursor,
sortBy: this.sortBy, sortBy: this.sortBy,
filterOnType: this.filterOnType, filterOnType: this.filterOnType,
}), StorageScope.WORKSPACE); }), StorageScope.WORKSPACE);
} }
restore(storageService: IStorageService): void { restore(): void {
let raw = storageService.get('outline/state', StorageScope.WORKSPACE); let raw = this._storageService.get('outline/state', StorageScope.WORKSPACE);
if (!raw) { if (!raw) {
return; return;
} }
...@@ -241,7 +249,7 @@ export class OutlinePane extends ViewPane { ...@@ -241,7 +249,7 @@ export class OutlinePane extends ViewPane {
private _disposables = new Array<IDisposable>(); private _disposables = new Array<IDisposable>();
private _editorDisposables = new DisposableStore(); private _editorDisposables = new DisposableStore();
private _outlineViewState = new OutlineViewState(); private _outlineViewState: OutlineViewState;
private _requestOracle?: RequestOracle; private _requestOracle?: RequestOracle;
private _domNode!: HTMLElement; private _domNode!: HTMLElement;
private _message!: HTMLDivElement; private _message!: HTMLDivElement;
...@@ -262,7 +270,6 @@ export class OutlinePane extends ViewPane { ...@@ -262,7 +270,6 @@ export class OutlinePane extends ViewPane {
@IInstantiationService private readonly _instantiationService: IInstantiationService, @IInstantiationService private readonly _instantiationService: IInstantiationService,
@IViewDescriptorService viewDescriptorService: IViewDescriptorService, @IViewDescriptorService viewDescriptorService: IViewDescriptorService,
@IThemeService private readonly _themeService: IThemeService, @IThemeService private readonly _themeService: IThemeService,
@IStorageService private readonly _storageService: IStorageService,
@ICodeEditorService private readonly _editorService: ICodeEditorService, @ICodeEditorService private readonly _editorService: ICodeEditorService,
@IMarkerDecorationsService private readonly _markerDecorationService: IMarkerDecorationsService, @IMarkerDecorationsService private readonly _markerDecorationService: IMarkerDecorationsService,
@IConfigurationService private readonly _configurationService: IConfigurationService, @IConfigurationService private readonly _configurationService: IConfigurationService,
...@@ -274,7 +281,7 @@ export class OutlinePane extends ViewPane { ...@@ -274,7 +281,7 @@ export class OutlinePane extends ViewPane {
@ITelemetryService telemetryService: ITelemetryService, @ITelemetryService telemetryService: ITelemetryService,
) { ) {
super(options, keybindingService, contextMenuService, _configurationService, contextKeyService, viewDescriptorService, _instantiationService, openerService, themeService, telemetryService); super(options, keybindingService, contextMenuService, _configurationService, contextKeyService, viewDescriptorService, _instantiationService, openerService, themeService, telemetryService);
this._outlineViewState.restore(this._storageService); this._outlineViewState = this.instantiationService.createInstance(OutlineViewState);
this._contextKeyFocused = OutlineViewFocused.bindTo(contextKeyService); this._contextKeyFocused = OutlineViewFocused.bindTo(contextKeyService);
this._contextKeyFiltered = OutlineViewFiltered.bindTo(contextKeyService); this._contextKeyFiltered = OutlineViewFiltered.bindTo(contextKeyService);
this._disposables.push(this.onDidFocus(_ => this._contextKeyFocused.set(true))); this._disposables.push(this.onDidFocus(_ => this._contextKeyFocused.set(true)));
...@@ -434,7 +441,7 @@ export class OutlinePane extends ViewPane { ...@@ -434,7 +441,7 @@ export class OutlinePane extends ViewPane {
} }
private _onDidChangeUserState(e: { followCursor?: boolean, sortBy?: boolean, filterOnType?: boolean }) { private _onDidChangeUserState(e: { followCursor?: boolean, sortBy?: boolean, filterOnType?: boolean }) {
this._outlineViewState.persist(this._storageService); this._outlineViewState.persist();
if (e.followCursor) { if (e.followCursor) {
// todo@joh update immediately // todo@joh update immediately
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册