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(); + } + }) }