Force kill tsserver on ts extension shutdown

This commit is contained in:
Matt Bierner
2017-07-12 11:12:48 -07:00
parent 5da27baff3
commit 0bf8b3c8f7
2 changed files with 25 additions and 5 deletions

View File

@@ -477,7 +477,9 @@ class TypeScriptServiceClientHost implements ITypescriptServiceClientHost {
this.versionStatus = new VersionStatus();
this.disposables.push(this.versionStatus);
this.client = new TypeScriptServiceClient(this, workspaceState, this.versionStatus, plugins, this.disposables);
this.client = new TypeScriptServiceClient(this, workspaceState, this.versionStatus, plugins);
this.disposables.push(this.client);
this.languagePerId = new Map();
for (const description of descriptions) {
const manager = new LanguageProvider(this.client, description);

View File

@@ -153,12 +153,13 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
private _apiVersion: API;
private telemetryReporter: TelemetryReporter;
private readonly disposables: Disposable[] = [];
constructor(
private readonly host: ITypescriptServiceClientHost,
private readonly workspaceState: Memento,
private readonly versionStatus: VersionStatus,
private readonly plugins: TypeScriptServerPlugin[],
disposables: Disposable[]
private readonly plugins: TypeScriptServerPlugin[]
) {
this.pathSeparator = path.sep;
this.lastStart = Date.now();
@@ -182,7 +183,7 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
this._apiVersion = new API('1.0.0');
this.tracer = new Tracer(this.logger);
disposables.push(workspace.onDidChangeConfiguration(() => {
this.disposables.push(workspace.onDidChangeConfiguration(() => {
const oldConfiguration = this.configuration;
this.configuration = TypeScriptServiceConfiguration.loadFromWorkspace();
@@ -200,10 +201,27 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
}
}));
this.telemetryReporter = new TelemetryReporter();
disposables.push(this.telemetryReporter);
this.disposables.push(this.telemetryReporter);
this.startService();
}
public dispose() {
if (this.servicePromise) {
this.servicePromise.then(cp => {
if (cp) {
cp.kill();
}
}).then(undefined, () => void 0);
}
while (this.disposables.length) {
const obj = this.disposables.pop();
if (obj) {
obj.dispose();
}
}
}
public restartTsServer(): void {
const start = () => {
this.servicePromise = this.startService(true);