mirror of
https://github.com/Microsoft/vscode
synced 2024-08-28 05:19:39 +00:00
debug: fix serverReadyAction.killOnServerStop not working (#195944)
Fixes #195942
This commit is contained in:
parent
c7521f9ab4
commit
9979a72abf
|
@ -53,11 +53,12 @@ class ServerReadyDetector extends vscode.Disposable {
|
||||||
private static detectors = new Map<vscode.DebugSession, ServerReadyDetector>();
|
private static detectors = new Map<vscode.DebugSession, ServerReadyDetector>();
|
||||||
private static terminalDataListener: vscode.Disposable | undefined;
|
private static terminalDataListener: vscode.Disposable | undefined;
|
||||||
|
|
||||||
|
private readonly stoppedEmitter = new vscode.EventEmitter<void>();
|
||||||
|
private readonly onDidSessionStop = this.stoppedEmitter.event;
|
||||||
|
private readonly disposables = new Set<vscode.Disposable>([]);
|
||||||
private trigger: Trigger;
|
private trigger: Trigger;
|
||||||
private shellPid?: number;
|
private shellPid?: number;
|
||||||
private regexp: RegExp;
|
private regexp: RegExp;
|
||||||
private disposables: vscode.Disposable[] = [];
|
|
||||||
private lateDisposables = new Set<vscode.Disposable>([]);
|
|
||||||
|
|
||||||
static start(session: vscode.DebugSession): ServerReadyDetector | undefined {
|
static start(session: vscode.DebugSession): ServerReadyDetector | undefined {
|
||||||
if (session.configuration.serverReadyAction) {
|
if (session.configuration.serverReadyAction) {
|
||||||
|
@ -75,6 +76,7 @@ class ServerReadyDetector extends vscode.Disposable {
|
||||||
const detector = ServerReadyDetector.detectors.get(session);
|
const detector = ServerReadyDetector.detectors.get(session);
|
||||||
if (detector) {
|
if (detector) {
|
||||||
ServerReadyDetector.detectors.delete(session);
|
ServerReadyDetector.detectors.delete(session);
|
||||||
|
detector.sessionStopped();
|
||||||
detector.dispose();
|
detector.dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -125,12 +127,11 @@ class ServerReadyDetector extends vscode.Disposable {
|
||||||
|
|
||||||
private internalDispose() {
|
private internalDispose() {
|
||||||
this.disposables.forEach(d => d.dispose());
|
this.disposables.forEach(d => d.dispose());
|
||||||
this.disposables = [];
|
this.disposables.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
override dispose() {
|
public sessionStopped() {
|
||||||
this.lateDisposables.forEach(d => d.dispose());
|
this.stoppedEmitter.fire();
|
||||||
return super.dispose();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
detectPattern(s: string): boolean {
|
detectPattern(s: string): boolean {
|
||||||
|
@ -139,7 +140,6 @@ class ServerReadyDetector extends vscode.Disposable {
|
||||||
if (matches && matches.length >= 1) {
|
if (matches && matches.length >= 1) {
|
||||||
this.openExternalWithString(this.session, matches.length > 1 ? matches[1] : '');
|
this.openExternalWithString(this.session, matches.length > 1 ? matches[1] : '');
|
||||||
this.trigger.fire();
|
this.trigger.fire();
|
||||||
this.internalDispose();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -147,7 +147,6 @@ class ServerReadyDetector extends vscode.Disposable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private openExternalWithString(session: vscode.DebugSession, captureString: string) {
|
private openExternalWithString(session: vscode.DebugSession, captureString: string) {
|
||||||
|
|
||||||
const args: ServerReadyAction = session.configuration.serverReadyAction;
|
const args: ServerReadyAction = session.configuration.serverReadyAction;
|
||||||
|
|
||||||
let uri;
|
let uri;
|
||||||
|
@ -228,14 +227,12 @@ class ServerReadyDetector extends vscode.Disposable {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const stopListener = vscode.debug.onDidTerminateDebugSession(async (terminated) => {
|
const stopListener = this.onDidSessionStop(async () => {
|
||||||
if (terminated === session) {
|
stopListener.dispose();
|
||||||
stopListener.dispose();
|
this.disposables.delete(stopListener);
|
||||||
this.lateDisposables.delete(stopListener);
|
await vscode.debug.stopDebugging(createdSession);
|
||||||
await vscode.debug.stopDebugging(createdSession);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
this.lateDisposables.add(stopListener);
|
this.disposables.add(stopListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
private startBrowserDebugSession(type: string, session: vscode.DebugSession, uri: string, trackerId?: string) {
|
private startBrowserDebugSession(type: string, session: vscode.DebugSession, uri: string, trackerId?: string) {
|
||||||
|
@ -272,14 +269,12 @@ class ServerReadyDetector extends vscode.Disposable {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const stopListener = vscode.debug.onDidTerminateDebugSession(async (terminated) => {
|
const stopListener = this.onDidSessionStop(async () => {
|
||||||
if (terminated === session) {
|
stopListener.dispose();
|
||||||
stopListener.dispose();
|
this.disposables.delete(stopListener);
|
||||||
this.lateDisposables.delete(stopListener);
|
await vscode.debug.stopDebugging(createdSession);
|
||||||
await vscode.debug.stopDebugging(createdSession);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
this.lateDisposables.add(stopListener);
|
this.disposables.add(stopListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
private catchStartedDebugSession(predicate: (session: vscode.DebugSession) => boolean, cancellationToken: vscode.CancellationToken): Promise<vscode.DebugSession | undefined> {
|
private catchStartedDebugSession(predicate: (session: vscode.DebugSession) => boolean, cancellationToken: vscode.CancellationToken): Promise<vscode.DebugSession | undefined> {
|
||||||
|
@ -287,8 +282,8 @@ class ServerReadyDetector extends vscode.Disposable {
|
||||||
const done = (value?: vscode.DebugSession) => {
|
const done = (value?: vscode.DebugSession) => {
|
||||||
listener.dispose();
|
listener.dispose();
|
||||||
cancellationListener.dispose();
|
cancellationListener.dispose();
|
||||||
this.lateDisposables.delete(listener);
|
this.disposables.delete(listener);
|
||||||
this.lateDisposables.delete(cancellationListener);
|
this.disposables.delete(cancellationListener);
|
||||||
_resolve(value);
|
_resolve(value);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -300,8 +295,8 @@ class ServerReadyDetector extends vscode.Disposable {
|
||||||
});
|
});
|
||||||
|
|
||||||
// In case the debug session of interest was never caught anyhow.
|
// In case the debug session of interest was never caught anyhow.
|
||||||
this.lateDisposables.add(listener);
|
this.disposables.add(listener);
|
||||||
this.lateDisposables.add(cancellationListener);
|
this.disposables.add(cancellationListener);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue