Provide project/file name in TypeScript loading indicator (#225643)

* Specify which project is loading at any given time. Provide an indicator for file opens.

* Just use `vscode.workspace.asRelativePath`.

* Remove unused import.
This commit is contained in:
Daniel Rosenwasser
2024-09-18 10:56:50 -07:00
committed by GitHub
parent 567d4ce7be
commit 75c0fc210a

View File

@@ -903,9 +903,14 @@ export default class TypeScriptServiceClient extends Disposable implements IType
if (command === 'updateOpen') {
// If update open has completed, consider that the project has loaded
Promise.all(executions).then(() => {
const updateOpenTask = Promise.all(executions).then(() => {
this.loadingIndicator.reset();
});
const updateOpenArgs = (args as Proto.UpdateOpenRequestArgs);
if (updateOpenArgs.openFiles?.length === 1) {
this.loadingIndicator.startedLoadingFile(updateOpenArgs.openFiles[0].file, updateOpenTask);
}
}
return executions[0]!;
@@ -1322,7 +1327,7 @@ function getDiagnosticsKind(event: Proto.Event) {
class ServerInitializingIndicator extends Disposable {
private _task?: { project: string | undefined; resolve: () => void };
private _task?: { project: string; resolve: () => void };
public reset(): void {
if (this._task) {
@@ -1334,20 +1339,30 @@ class ServerInitializingIndicator extends Disposable {
/**
* Signal that a project has started loading.
*/
public startedLoadingProject(projectName: string | undefined): void {
public startedLoadingProject(projectName: string): void {
// TS projects are loaded sequentially. Cancel existing task because it should always be resolved before
// the incoming project loading task is.
this.reset();
const projectDisplayName = vscode.workspace.asRelativePath(projectName);
vscode.window.withProgress({
location: vscode.ProgressLocation.Window,
title: vscode.l10n.t("Initializing JS/TS language features"),
title: vscode.l10n.t("Initializing project '{0}'", projectDisplayName),
}, () => new Promise<void>(resolve => {
this._task = { project: projectName, resolve };
}));
}
public finishedLoadingProject(projectName: string | undefined): void {
public startedLoadingFile(fileName: string, task: Promise<unknown>): void {
if (!this._task) {
vscode.window.withProgress({
location: vscode.ProgressLocation.Window,
title: vscode.l10n.t("Analyzing '{0}' and its dependencies", path.basename(fileName)),
}, () => task);
}
}
public finishedLoadingProject(projectName: string): void {
if (this._task && this._task.project === projectName) {
this._task.resolve();
this._task = undefined;