mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-08 17:24:01 -05:00
Merge from vscode a348d103d1256a06a2c9b3f9b406298a9fef6898 (#15681)
* Merge from vscode a348d103d1256a06a2c9b3f9b406298a9fef6898 * Fixes and cleanup * Distro * Fix hygiene yarn * delete no yarn lock changes file * Fix hygiene * Fix layer check * Fix CI * Skip lib checks * Remove tests deleted in vs code * Fix tests * Distro * Fix tests and add removed extension point * Skip failing notebook tests for now * Disable broken tests and cleanup build folder * Update yarn.lock and fix smoke tests * Bump sqlite * fix contributed actions and file spacing * Fix user data path * Update yarn.locks Co-authored-by: ADS Merger <karlb@microsoft.com>
This commit is contained in:
@@ -7,6 +7,7 @@ import type * as vscode from 'vscode';
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { ExtHostStorage } from 'vs/workbench/api/common/extHostStorage';
|
||||
import { IExtensionDescription } from 'vs/platform/extensions/common/extensions';
|
||||
import { DeferredPromise, RunOnceScheduler } from 'vs/base/common/async';
|
||||
|
||||
export class ExtensionMemento implements vscode.Memento {
|
||||
|
||||
@@ -18,6 +19,9 @@ export class ExtensionMemento implements vscode.Memento {
|
||||
private _value?: { [n: string]: any; };
|
||||
private readonly _storageListener: IDisposable;
|
||||
|
||||
private _deferredPromises: Map<string, DeferredPromise<void>> = new Map();
|
||||
private _scheduler: RunOnceScheduler;
|
||||
|
||||
constructor(id: string, global: boolean, storage: ExtHostStorage) {
|
||||
this._id = id;
|
||||
this._shared = global;
|
||||
@@ -33,6 +37,23 @@ export class ExtensionMemento implements vscode.Memento {
|
||||
this._value = e.value;
|
||||
}
|
||||
});
|
||||
|
||||
this._scheduler = new RunOnceScheduler(() => {
|
||||
const records = this._deferredPromises;
|
||||
this._deferredPromises = new Map();
|
||||
(async () => {
|
||||
try {
|
||||
await this._storage.setValue(this._shared, this._id, this._value!);
|
||||
for (const value of records.values()) {
|
||||
value.complete();
|
||||
}
|
||||
} catch (e) {
|
||||
for (const value of records.values()) {
|
||||
value.error(e);
|
||||
}
|
||||
}
|
||||
})();
|
||||
}, 0);
|
||||
}
|
||||
|
||||
get whenReady(): Promise<ExtensionMemento> {
|
||||
@@ -51,7 +72,20 @@ export class ExtensionMemento implements vscode.Memento {
|
||||
|
||||
update(key: string, value: any): Promise<void> {
|
||||
this._value![key] = value;
|
||||
return this._storage.setValue(this._shared, this._id, this._value!);
|
||||
|
||||
let record = this._deferredPromises.get(key);
|
||||
if (record !== undefined) {
|
||||
return record.p;
|
||||
}
|
||||
|
||||
const promise = new DeferredPromise<void>();
|
||||
this._deferredPromises.set(key, promise);
|
||||
|
||||
if (!this._scheduler.isScheduled()) {
|
||||
this._scheduler.schedule();
|
||||
}
|
||||
|
||||
return promise.p;
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
|
||||
Reference in New Issue
Block a user