forked from OSchip/llvm-project
[clangd] Clean the cache of file statuses on vscode-clangd when clangd crashes.
Summary: Clear the cached file statuses, otherwise we will leave some garbage texts on the status bar when clangd crashes. Reviewers: ilya-biryukov Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D56540 llvm-svn: 352049
This commit is contained in:
parent
55787a7e77
commit
66038ffa13
|
@ -40,6 +40,11 @@ class FileStatus {
|
|||
this.statusBarItem.show();
|
||||
}
|
||||
|
||||
clear() {
|
||||
this.statuses.clear();
|
||||
this.statusBarItem.hide();
|
||||
}
|
||||
|
||||
dispose() {
|
||||
this.statusBarItem.dispose();
|
||||
}
|
||||
|
@ -112,9 +117,16 @@ export function activate(context: vscode.ExtensionContext) {
|
|||
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();
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue