提交 ed3e4909 编写于 作者: J Johannes Rieken

add storage sync logic #62365

上级 8b32ed7c
......@@ -217,10 +217,10 @@ class SuggestMemoryService extends Disposable implements ISuggestMemoryService {
const update = () => {
const mode = this._configService.getValue<MemMode>('editor.suggestSelection');
const share = this._configService.getValue<boolean>('editor.suggest.shareSuggestSelections');
this._update(mode, share);
this._update(mode, share, false);
};
this._persistSoon = this._register(new RunOnceScheduler(() => this._saveState(), 3000));
this._persistSoon = this._register(new RunOnceScheduler(() => this._saveState(), 500));
this._register(_storageService.onWillSaveState(() => this._saveState()));
this._register(this._configService.onDidChangeConfiguration(e => {
......@@ -228,16 +228,20 @@ class SuggestMemoryService extends Disposable implements ISuggestMemoryService {
update();
}
}));
// this._register(this._storageService.onDidChangeStorage(e => {
// if (e.scope === StorageScope.GLOBAL && e.key.indexOf(this._storagePrefix) === 0) {
// update();
// }
// }));
this._register(this._storageService.onDidChangeStorage(e => {
if (e.scope === StorageScope.GLOBAL && e.key.indexOf(this._storagePrefix) === 0) {
if (!document.hasFocus()) {
// windows that aren't focused have to drop their current
// storage value and accept what's stored now
this._update(this._mode, this._shareMem, true);
}
}
}));
update();
}
private _update(mode: MemMode, shareMem: boolean): void {
if (this._mode === mode && this._shareMem === shareMem) {
private _update(mode: MemMode, shareMem: boolean, force: boolean): void {
if (!force && this._mode === mode && this._shareMem === shareMem) {
return;
}
this._shareMem = shareMem;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册