mirror of
https://github.com/coder/code-server.git
synced 2026-05-15 08:47:26 +02:00
Merge commit 'be3e8236086165e5e45a5a10783823874b3f3ebd' as 'lib/vscode'
This commit is contained in:
45
lib/vscode/src/vs/workbench/common/component.ts
Normal file
45
lib/vscode/src/vs/workbench/common/component.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Memento, MementoObject } from 'vs/workbench/common/memento';
|
||||
import { IThemeService, Themable } from 'vs/platform/theme/common/themeService';
|
||||
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
|
||||
|
||||
export class Component extends Themable {
|
||||
|
||||
private readonly memento: Memento;
|
||||
|
||||
constructor(
|
||||
private readonly id: string,
|
||||
themeService: IThemeService,
|
||||
storageService: IStorageService
|
||||
) {
|
||||
super(themeService);
|
||||
|
||||
this.id = id;
|
||||
this.memento = new Memento(this.id, storageService);
|
||||
|
||||
this._register(storageService.onWillSaveState(() => {
|
||||
|
||||
// Ask the component to persist state into the memento
|
||||
this.saveState();
|
||||
|
||||
// Then save the memento into storage
|
||||
this.memento.saveMemento();
|
||||
}));
|
||||
}
|
||||
|
||||
getId(): string {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
protected getMemento(scope: StorageScope): MementoObject {
|
||||
return this.memento.getMemento(scope);
|
||||
}
|
||||
|
||||
protected saveState(): void {
|
||||
// Subclasses to implement for storing state
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user