hokein updated this revision to Diff 185736. hokein added a comment. Fix space.
Repository: rCTE Clang Tools Extra CHANGES SINCE LAST ACTION https://reviews.llvm.org/D57884/new/ https://reviews.llvm.org/D57884 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 @@ -12,6 +12,25 @@ return config.get<T>(option, defaultValue); } +class NoRestartErrorHandler implements vscodelc.ErrorHandler { + // Mirror the implementation of DefaultErrorHandler which is not exposed in + // vscode-languageclient. + public error(_error: Error, _message: vscodelc.Message, count: number): vscodelc.ErrorAction { + if (count && count <= 3) { + return vscodelc.ErrorAction.Continue; + } + return vscodelc.ErrorAction.Shutdown; + } + public closed(): vscodelc.CloseAction { + // The default implementation will restarts clangd up to 5 times if clangd + // crashes. We don't restart clangd -- this'd make the life of tracking/reporting + // crashes easier, and sometimes restart doesn't help as the file state + // is usually broken (files are not opened, etc). + vscode.window.showErrorMessage(`The clangd crashed, please reload the window to restart.`); + return vscodelc.CloseAction.DoNotRestart; + } +} + namespace SwitchSourceHeaderRequest { export const type = new vscodelc.RequestType<vscodelc.TextDocumentIdentifier, string|undefined, @@ -88,6 +107,7 @@ protocol2Code: (value: string) => vscode.Uri.file(realpathSync(vscode.Uri.parse(value).fsPath)) }, + errorHandler: new NoRestartErrorHandler(), // Do not switch to output window when clangd returns output revealOutputChannelOn: vscodelc.RevealOutputChannelOn.Never };
Index: clangd/clients/clangd-vscode/src/extension.ts =================================================================== --- clangd/clients/clangd-vscode/src/extension.ts +++ clangd/clients/clangd-vscode/src/extension.ts @@ -12,6 +12,25 @@ return config.get<T>(option, defaultValue); } +class NoRestartErrorHandler implements vscodelc.ErrorHandler { + // Mirror the implementation of DefaultErrorHandler which is not exposed in + // vscode-languageclient. + public error(_error: Error, _message: vscodelc.Message, count: number): vscodelc.ErrorAction { + if (count && count <= 3) { + return vscodelc.ErrorAction.Continue; + } + return vscodelc.ErrorAction.Shutdown; + } + public closed(): vscodelc.CloseAction { + // The default implementation will restarts clangd up to 5 times if clangd + // crashes. We don't restart clangd -- this'd make the life of tracking/reporting + // crashes easier, and sometimes restart doesn't help as the file state + // is usually broken (files are not opened, etc). + vscode.window.showErrorMessage(`The clangd crashed, please reload the window to restart.`); + return vscodelc.CloseAction.DoNotRestart; + } +} + namespace SwitchSourceHeaderRequest { export const type = new vscodelc.RequestType<vscodelc.TextDocumentIdentifier, string|undefined, @@ -88,6 +107,7 @@ protocol2Code: (value: string) => vscode.Uri.file(realpathSync(vscode.Uri.parse(value).fsPath)) }, + errorHandler: new NoRestartErrorHandler(), // Do not switch to output window when clangd returns output revealOutputChannelOn: vscodelc.RevealOutputChannelOn.Never };
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits