mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-09 01:32:34 -05:00
Merge VS Code 1.31.1 (#4283)
This commit is contained in:
@@ -24,7 +24,7 @@ export interface BeforeShutdownEvent {
|
||||
* Allows to veto the shutdown. The veto can be a long running operation but it
|
||||
* will block the application from closing.
|
||||
*/
|
||||
veto(value: boolean | Thenable<boolean>): void;
|
||||
veto(value: boolean | Promise<boolean>): void;
|
||||
|
||||
/**
|
||||
* The reason why the application will be shutting down.
|
||||
@@ -46,7 +46,7 @@ export interface WillShutdownEvent {
|
||||
* Allows to join the shutdown. The promise can be a long running operation but it
|
||||
* will block the application from closing.
|
||||
*/
|
||||
join(promise: Thenable<void>): void;
|
||||
join(promise: Promise<void>): void;
|
||||
|
||||
/**
|
||||
* The reason why the application is shutting down.
|
||||
@@ -162,7 +162,7 @@ export interface ILifecycleService {
|
||||
* Returns a promise that resolves when a certain lifecycle phase
|
||||
* has started.
|
||||
*/
|
||||
when(phase: LifecyclePhase): Thenable<void>;
|
||||
when(phase: LifecyclePhase): Promise<void>;
|
||||
}
|
||||
|
||||
export const NullLifecycleService: ILifecycleService = {
|
||||
@@ -176,12 +176,12 @@ export const NullLifecycleService: ILifecycleService = {
|
||||
};
|
||||
|
||||
// Shared veto handling across main and renderer
|
||||
export function handleVetos(vetos: (boolean | Thenable<boolean>)[], onError: (error: Error) => void): Promise<boolean /* veto */> {
|
||||
export function handleVetos(vetos: (boolean | Promise<boolean>)[], onError: (error: Error) => void): Promise<boolean /* veto */> {
|
||||
if (vetos.length === 0) {
|
||||
return Promise.resolve(false);
|
||||
}
|
||||
|
||||
const promises: Thenable<void>[] = [];
|
||||
const promises: Promise<void>[] = [];
|
||||
let lazyValue = false;
|
||||
|
||||
for (let valueOrPromise of vetos) {
|
||||
|
||||
@@ -42,10 +42,10 @@ export class LifecycleService extends Disposable implements ILifecycleService {
|
||||
private shutdownReason: ShutdownReason;
|
||||
|
||||
constructor(
|
||||
@INotificationService private notificationService: INotificationService,
|
||||
@IWindowService private windowService: IWindowService,
|
||||
@IStorageService private storageService: IStorageService,
|
||||
@ILogService private logService: ILogService
|
||||
@INotificationService private readonly notificationService: INotificationService,
|
||||
@IWindowService private readonly windowService: IWindowService,
|
||||
@IStorageService private readonly storageService: IStorageService,
|
||||
@ILogService private readonly logService: ILogService
|
||||
) {
|
||||
super();
|
||||
|
||||
@@ -116,7 +116,7 @@ export class LifecycleService extends Disposable implements ILifecycleService {
|
||||
}
|
||||
|
||||
private handleBeforeShutdown(reason: ShutdownReason): Promise<boolean> {
|
||||
const vetos: (boolean | Thenable<boolean>)[] = [];
|
||||
const vetos: (boolean | Promise<boolean>)[] = [];
|
||||
|
||||
this._onBeforeShutdown.fire({
|
||||
veto(value) {
|
||||
@@ -131,8 +131,8 @@ export class LifecycleService extends Disposable implements ILifecycleService {
|
||||
});
|
||||
}
|
||||
|
||||
private handleWillShutdown(reason: ShutdownReason): Thenable<void> {
|
||||
const joiners: Thenable<void>[] = [];
|
||||
private handleWillShutdown(reason: ShutdownReason): Promise<void> {
|
||||
const joiners: Promise<void>[] = [];
|
||||
|
||||
this._onWillShutdown.fire({
|
||||
join(promise) {
|
||||
@@ -143,7 +143,7 @@ export class LifecycleService extends Disposable implements ILifecycleService {
|
||||
reason
|
||||
});
|
||||
|
||||
return Promise.all(joiners).then(() => void 0, err => {
|
||||
return Promise.all(joiners).then(() => undefined, err => {
|
||||
this.notificationService.error(toErrorMessage(err));
|
||||
onUnexpectedError(err);
|
||||
});
|
||||
@@ -163,13 +163,14 @@ export class LifecycleService extends Disposable implements ILifecycleService {
|
||||
this._phase = value;
|
||||
mark(`LifecyclePhase/${LifecyclePhaseToString(value)}`);
|
||||
|
||||
if (this.phaseWhen.has(this._phase)) {
|
||||
this.phaseWhen.get(this._phase).open();
|
||||
const barrier = this.phaseWhen.get(this._phase);
|
||||
if (barrier) {
|
||||
barrier.open();
|
||||
this.phaseWhen.delete(this._phase);
|
||||
}
|
||||
}
|
||||
|
||||
when(phase: LifecyclePhase): Thenable<any> {
|
||||
when(phase: LifecyclePhase): Promise<any> {
|
||||
if (phase <= this._phase) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ import { ICodeWindow } from 'vs/platform/windows/electron-main/windows';
|
||||
import { handleVetos } from 'vs/platform/lifecycle/common/lifecycle';
|
||||
import { isMacintosh, isWindows } from 'vs/base/common/platform';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { always } from 'vs/base/common/async';
|
||||
|
||||
export const ILifecycleService = createDecorator<ILifecycleService>('lifecycleService');
|
||||
|
||||
@@ -26,7 +25,7 @@ export const enum UnloadReason {
|
||||
export interface IWindowUnloadEvent {
|
||||
window: ICodeWindow;
|
||||
reason: UnloadReason;
|
||||
veto(value: boolean | Thenable<boolean>): void;
|
||||
veto(value: boolean | Promise<boolean>): void;
|
||||
}
|
||||
|
||||
export interface ShutdownEvent {
|
||||
@@ -35,7 +34,7 @@ export interface ShutdownEvent {
|
||||
* Allows to join the shutdown. The promise can be a long running operation but it
|
||||
* will block the application from closing.
|
||||
*/
|
||||
join(promise: Thenable<void>): void;
|
||||
join(promise: Promise<void>): void;
|
||||
}
|
||||
|
||||
export interface ILifecycleService {
|
||||
@@ -79,7 +78,7 @@ export interface ILifecycleService {
|
||||
/**
|
||||
* Unload a window for the provided reason. All lifecycle event handlers are triggered.
|
||||
*/
|
||||
unload(window: ICodeWindow, reason: UnloadReason): Thenable<boolean /* veto */>;
|
||||
unload(window: ICodeWindow, reason: UnloadReason): Promise<boolean /* veto */>;
|
||||
|
||||
/**
|
||||
* Restart the application with optional arguments (CLI). All lifecycle event handlers are triggered.
|
||||
@@ -89,7 +88,7 @@ export interface ILifecycleService {
|
||||
/**
|
||||
* Shutdown the application normally. All lifecycle event handlers are triggered.
|
||||
*/
|
||||
quit(fromUpdate?: boolean): Thenable<boolean /* veto */>;
|
||||
quit(fromUpdate?: boolean): Promise<boolean /* veto */>;
|
||||
|
||||
/**
|
||||
* Forcefully shutdown the application. No livecycle event handlers are triggered.
|
||||
@@ -107,10 +106,10 @@ export class LifecycleService extends Disposable implements ILifecycleService {
|
||||
private oneTimeListenerTokenGenerator = 0;
|
||||
private windowCounter = 0;
|
||||
|
||||
private pendingQuitPromise: Thenable<boolean> | null;
|
||||
private pendingQuitPromise: Promise<boolean> | null;
|
||||
private pendingQuitPromiseResolve: { (veto: boolean): void } | null;
|
||||
|
||||
private pendingWillShutdownPromise: Thenable<void> | null;
|
||||
private pendingWillShutdownPromise: Promise<void> | null;
|
||||
|
||||
private _quitRequested = false;
|
||||
get quitRequested(): boolean { return this._quitRequested; }
|
||||
@@ -131,8 +130,8 @@ export class LifecycleService extends Disposable implements ILifecycleService {
|
||||
readonly onBeforeWindowUnload: Event<IWindowUnloadEvent> = this._onBeforeWindowUnload.event;
|
||||
|
||||
constructor(
|
||||
@ILogService private logService: ILogService,
|
||||
@IStateService private stateService: IStateService
|
||||
@ILogService private readonly logService: ILogService,
|
||||
@IStateService private readonly stateService: IStateService
|
||||
) {
|
||||
super();
|
||||
|
||||
@@ -202,7 +201,7 @@ export class LifecycleService extends Disposable implements ILifecycleService {
|
||||
const shutdownPromise = this.beginOnWillShutdown();
|
||||
|
||||
// Wait until shutdown is signaled to be complete
|
||||
always(shutdownPromise, () => {
|
||||
shutdownPromise.finally(() => {
|
||||
|
||||
// Resolve pending quit promise now without veto
|
||||
this.resolvePendingQuitPromise(false /* no veto */);
|
||||
@@ -217,14 +216,14 @@ export class LifecycleService extends Disposable implements ILifecycleService {
|
||||
});
|
||||
}
|
||||
|
||||
private beginOnWillShutdown(): Thenable<void> {
|
||||
private beginOnWillShutdown(): Promise<void> {
|
||||
if (this.pendingWillShutdownPromise) {
|
||||
return this.pendingWillShutdownPromise; // shutdown is already running
|
||||
}
|
||||
|
||||
this.logService.trace('Lifecycle#onWillShutdown.fire()');
|
||||
|
||||
const joiners: Thenable<void>[] = [];
|
||||
const joiners: Promise<void>[] = [];
|
||||
|
||||
this._onWillShutdown.fire({
|
||||
join(promise) {
|
||||
@@ -234,7 +233,7 @@ export class LifecycleService extends Disposable implements ILifecycleService {
|
||||
}
|
||||
});
|
||||
|
||||
this.pendingWillShutdownPromise = Promise.all(joiners).then(null, err => this.logService.error(err));
|
||||
this.pendingWillShutdownPromise = Promise.all(joiners).then(undefined, err => this.logService.error(err));
|
||||
|
||||
return this.pendingWillShutdownPromise;
|
||||
}
|
||||
@@ -292,7 +291,7 @@ export class LifecycleService extends Disposable implements ILifecycleService {
|
||||
});
|
||||
}
|
||||
|
||||
unload(window: ICodeWindow, reason: UnloadReason): Thenable<boolean /* veto */> {
|
||||
unload(window: ICodeWindow, reason: UnloadReason): Promise<boolean /* veto */> {
|
||||
|
||||
// Always allow to unload a window that is not yet ready
|
||||
if (!window.isReady) {
|
||||
@@ -348,7 +347,7 @@ export class LifecycleService extends Disposable implements ILifecycleService {
|
||||
}
|
||||
}
|
||||
|
||||
private onBeforeUnloadWindowInRenderer(window: ICodeWindow, reason: UnloadReason): Thenable<boolean /* veto */> {
|
||||
private onBeforeUnloadWindowInRenderer(window: ICodeWindow, reason: UnloadReason): Promise<boolean /* veto */> {
|
||||
return new Promise<boolean>(c => {
|
||||
const oneTimeEventToken = this.oneTimeListenerTokenGenerator++;
|
||||
const okChannel = `vscode:ok${oneTimeEventToken}`;
|
||||
@@ -366,8 +365,8 @@ export class LifecycleService extends Disposable implements ILifecycleService {
|
||||
});
|
||||
}
|
||||
|
||||
private onBeforeUnloadWindowInMain(window: ICodeWindow, reason: UnloadReason): Thenable<boolean /* veto */> {
|
||||
const vetos: (boolean | Thenable<boolean>)[] = [];
|
||||
private onBeforeUnloadWindowInMain(window: ICodeWindow, reason: UnloadReason): Promise<boolean /* veto */> {
|
||||
const vetos: (boolean | Promise<boolean>)[] = [];
|
||||
|
||||
this._onBeforeWindowUnload.fire({
|
||||
reason,
|
||||
@@ -380,7 +379,7 @@ export class LifecycleService extends Disposable implements ILifecycleService {
|
||||
return handleVetos(vetos, err => this.logService.error(err));
|
||||
}
|
||||
|
||||
private onWillUnloadWindowInRenderer(window: ICodeWindow, reason: UnloadReason): Thenable<void> {
|
||||
private onWillUnloadWindowInRenderer(window: ICodeWindow, reason: UnloadReason): Promise<void> {
|
||||
return new Promise<void>(resolve => {
|
||||
const oneTimeEventToken = this.oneTimeListenerTokenGenerator++;
|
||||
const replyChannel = `vscode:reply${oneTimeEventToken}`;
|
||||
@@ -395,7 +394,7 @@ export class LifecycleService extends Disposable implements ILifecycleService {
|
||||
* A promise that completes to indicate if the quit request has been veto'd
|
||||
* by the user or not.
|
||||
*/
|
||||
quit(fromUpdate?: boolean): Thenable<boolean /* veto */> {
|
||||
quit(fromUpdate?: boolean): Promise<boolean /* veto */> {
|
||||
if (this.pendingQuitPromise) {
|
||||
return this.pendingQuitPromise;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user