[PATCH] D56540: [clangd] Clean the cache of file statuses on vscode-clangd when clangd crashes.
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 10 05:14:24 PST 2019
hokein created this revision.
hokein added a reviewer: ilya-biryukov.
Herald added subscribers: kadircet, arphaman, jkorous, MaskRay, ioeric.
Clear the cached file statuses, otherwise We will leave some garbage texts on
the status bar when clangd crashes.
Repository:
rCTE Clang Tools Extra
https://reviews.llvm.org/D56540
Files:
clangd/clients/clangd-vscode/src/extension.ts
Index: clangd/clients/clangd-vscode/src/extension.ts
===================================================================
--- clangd/clients/clangd-vscode/src/extension.ts
+++ clangd/clients/clangd-vscode/src/extension.ts
@@ -40,6 +40,11 @@
this.statusBarItem.show();
}
+ clear() {
+ this.statuses.clear();
+ this.statusBarItem.hide();
+ }
+
dispose() {
this.statusBarItem.dispose();
}
@@ -112,9 +117,16 @@
context.subscriptions.push(vscode.window.onDidChangeActiveTextEditor(() => {
status.updateStatus();
}));
- clangdClient.onReady().then(() => {
- clangdClient.onNotification(
- 'textDocument/clangd.fileStatus',
- (fileStatus) => { status.onFileUpdated(fileStatus); });
- })
+ clangdClient.onDidChangeState(
+ ({ newState }) => {
+ if (newState == vscodelc.State.Running) {
+ // clangd starts or restarts after crash.
+ clangdClient.onNotification(
+ 'textDocument/clangd.fileStatus',
+ (fileStatus) => { status.onFileUpdated(fileStatus); });
+ } else if (newState == vscodelc.State.Stopped) {
+ // Clear all cached statuses when clangd crashes.
+ status.clear();
+ }
+ })
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D56540.181035.patch
Type: text/x-patch
Size: 1337 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190110/99ce5556/attachment.bin>
More information about the cfe-commits
mailing list