Skip to content
This repository was archived by the owner on Nov 18, 2022. It is now read-only.

Commit 61a3864

Browse files
committed
Display in status bar the current state of RLS workspace
1 parent 310539b commit 61a3864

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

src/extension.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,13 @@ function onDidChangeActiveTextEditor(editor: TextEditor | undefined) {
108108

109109
activeWorkspace = workspace;
110110

111-
const updateProgress = (progress: { message: string } | null) => {
112-
if (progress) {
111+
const updateProgress = (progress: WorkspaceProgress) => {
112+
if (progress.state === 'progress') {
113113
startSpinner(`[${workspace.folder.name}] ${progress.message}`);
114114
} else {
115-
stopSpinner(`[${workspace.folder.name}]`);
115+
const readySymbol =
116+
progress.state === 'standby' ? '$(debug-stop)' : '$(debug-start)';
117+
stopSpinner(`[${workspace.folder.name}] ${readySymbol}`);
116118
}
117119
};
118120

@@ -166,6 +168,11 @@ function clientWorkspaceForUri(
166168
return workspaces.get(folder.uri.toString());
167169
}
168170

171+
/** Denotes the state or progress the workspace is currently in. */
172+
type WorkspaceProgress =
173+
| { state: 'progress'; message: string }
174+
| { state: 'ready' | 'standby' };
175+
169176
// We run one RLS and one corresponding language client per workspace folder
170177
// (VSCode workspace, not Cargo workspace). This class contains all the per-client
171178
// and per-workspace stuff.
@@ -176,7 +183,7 @@ class ClientWorkspace {
176183
private readonly config: RLSConfiguration;
177184
private lc: LanguageClient | null = null;
178185
private disposables: Disposable[];
179-
private _progress: Observable<{ message: string } | null>;
186+
private _progress: Observable<WorkspaceProgress>;
180187
get progress() {
181188
return this._progress;
182189
}
@@ -185,7 +192,7 @@ class ClientWorkspace {
185192
this.config = RLSConfiguration.loadFromWorkspace(folder.uri.fsPath);
186193
this.folder = folder;
187194
this.disposables = [];
188-
this._progress = new Observable<{ message: string } | null>(null);
195+
this._progress = new Observable<WorkspaceProgress>({ state: 'standby' });
189196
}
190197

191198
/**
@@ -198,7 +205,7 @@ class ClientWorkspace {
198205
}
199206

200207
public async start() {
201-
this._progress.value = { message: 'Starting' };
208+
this._progress.value = { state: 'progress', message: 'Starting' };
202209

203210
const serverOptions: ServerOptions = async () => {
204211
await this.autoUpdate();
@@ -275,6 +282,7 @@ class ClientWorkspace {
275282
if (this.lc) {
276283
await this.lc.stop();
277284
this.lc = null;
285+
this._progress.value = { state: 'standby' };
278286
}
279287

280288
this.disposables.forEach(d => d.dispose());
@@ -318,9 +326,9 @@ class ClientWorkspace {
318326
} else if (progress.title) {
319327
status = `[${progress.title.toLowerCase()}]`;
320328
}
321-
this._progress.value = { message: status };
329+
this._progress.value = { state: 'progress', message: status };
322330
} else {
323-
this._progress.value = null;
331+
this._progress.value = { state: 'ready' };
324332
}
325333
},
326334
);

0 commit comments

Comments
 (0)