mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-24 02:28:34 +01:00
Fix race on 'projectInfo' requests
Fixes #101076 Make sure we fully start the TS Server (including uploading files) before sending the 'projectInfo' request for the status bar item
This commit is contained in:
@@ -50,7 +50,6 @@ export default class TypeScriptServiceClientHost extends Disposable {
|
||||
private readonly languagePerId = new Map<string, LanguageProvider>();
|
||||
|
||||
private readonly typingsStatus: TypingsStatus;
|
||||
private readonly versionStatus: VersionStatus;
|
||||
|
||||
private readonly fileConfigurationManager: FileConfigurationManager;
|
||||
|
||||
@@ -69,7 +68,6 @@ export default class TypeScriptServiceClientHost extends Disposable {
|
||||
const allModeIds = this.getAllModeIds(descriptions, pluginManager);
|
||||
this.client = this._register(new TypeScriptServiceClient(
|
||||
workspaceState,
|
||||
version => this.versionStatus.onDidChangeTypeScriptVersion(version),
|
||||
pluginManager,
|
||||
logDirectoryProvider,
|
||||
allModeIds));
|
||||
@@ -81,8 +79,7 @@ export default class TypeScriptServiceClientHost extends Disposable {
|
||||
this.client.onConfigDiagnosticsReceived(diag => this.configFileDiagnosticsReceived(diag), null, this._disposables);
|
||||
this.client.onResendModelsRequested(() => this.populateService(), null, this._disposables);
|
||||
|
||||
this.versionStatus = this._register(new VersionStatus(this.client, commandManager));
|
||||
|
||||
this._register(new VersionStatus(this.client, commandManager));
|
||||
this._register(new AtaProgressReporter(this.client));
|
||||
this.typingsStatus = this._register(new TypingsStatus(this.client));
|
||||
this.fileConfigurationManager = this._register(new FileConfigurationManager(this.client));
|
||||
|
||||
@@ -9,6 +9,7 @@ import * as Proto from './protocol';
|
||||
import API from './utils/api';
|
||||
import { TypeScriptServiceConfiguration } from './utils/configuration';
|
||||
import { PluginManager } from './utils/plugins';
|
||||
import { TypeScriptVersion } from './utils/versionProvider';
|
||||
|
||||
export namespace ServerResponse {
|
||||
|
||||
@@ -113,7 +114,7 @@ export interface ITypeScriptServiceClient {
|
||||
|
||||
getWorkspaceRootForResource(resource: vscode.Uri): string | undefined;
|
||||
|
||||
readonly onTsServerStarted: vscode.Event<API>;
|
||||
readonly onTsServerStarted: vscode.Event<{ version: TypeScriptVersion, usedApiVersion: API }>;
|
||||
readonly onProjectLanguageServiceStateChanged: vscode.Event<Proto.ProjectLanguageServiceStateEventBody>;
|
||||
readonly onDidBeginInstallTypings: vscode.Event<Proto.BeginInstallTypesEventBody>;
|
||||
readonly onDidEndInstallTypings: vscode.Event<Proto.EndInstallTypesEventBody>;
|
||||
|
||||
@@ -121,7 +121,6 @@ export default class TypeScriptServiceClient extends Disposable implements IType
|
||||
|
||||
constructor(
|
||||
private readonly workspaceState: vscode.Memento,
|
||||
private readonly onDidChangeTypeScriptVersion: (version: TypeScriptVersion) => void,
|
||||
public readonly pluginManager: PluginManager,
|
||||
private readonly logDirectoryProvider: LogDirectoryProvider,
|
||||
allModeIds: readonly string[]
|
||||
@@ -239,7 +238,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType
|
||||
this.serverState = this.startService(true);
|
||||
}
|
||||
|
||||
private readonly _onTsServerStarted = this._register(new vscode.EventEmitter<API>());
|
||||
private readonly _onTsServerStarted = this._register(new vscode.EventEmitter<{ version: TypeScriptVersion, usedApiVersion: API }>());
|
||||
public readonly onTsServerStarted = this._onTsServerStarted.event;
|
||||
|
||||
private readonly _onDiagnosticsReceived = this._register(new vscode.EventEmitter<TsDiagnostics>());
|
||||
@@ -339,7 +338,6 @@ export default class TypeScriptServiceClient extends Disposable implements IType
|
||||
onFatalError: (command, err) => this.fatalError(command, err),
|
||||
});
|
||||
this.serverState = new ServerState.Running(handle, apiVersion, undefined, true);
|
||||
this.onDidChangeTypeScriptVersion(version);
|
||||
this.lastStart = Date.now();
|
||||
|
||||
/* __GDPR__
|
||||
@@ -416,15 +414,15 @@ export default class TypeScriptServiceClient extends Disposable implements IType
|
||||
handle.onReaderError(error => this.error('ReaderError', error));
|
||||
handle.onEvent(event => this.dispatchEvent(event));
|
||||
|
||||
this._onReady!.resolve();
|
||||
this._onTsServerStarted.fire(apiVersion);
|
||||
|
||||
if (apiVersion.gte(API.v300)) {
|
||||
this.loadingIndicator.startedLoadingProject(undefined /* projectName */);
|
||||
}
|
||||
|
||||
this.serviceStarted(resendModels);
|
||||
|
||||
this._onReady!.resolve();
|
||||
this._onTsServerStarted.fire({ version: version, usedApiVersion: apiVersion });
|
||||
|
||||
return this.serverState;
|
||||
}
|
||||
|
||||
|
||||
@@ -151,9 +151,11 @@ export default class VersionStatus extends Disposable {
|
||||
this._ready = true;
|
||||
this.updateStatus();
|
||||
});
|
||||
|
||||
this._register(this._client.onTsServerStarted(({ version }) => this.onDidChangeTypeScriptVersion(version)));
|
||||
}
|
||||
|
||||
public onDidChangeTypeScriptVersion(version: TypeScriptVersion) {
|
||||
private onDidChangeTypeScriptVersion(version: TypeScriptVersion) {
|
||||
this._statusBarEntry.text = version.displayName;
|
||||
this._statusBarEntry.tooltip = version.path;
|
||||
this.updateStatus();
|
||||
|
||||
Reference in New Issue
Block a user