Prevent compiler errors from terminating the language server process

This commit is contained in:
faldor20 2024-12-02 04:15:33 +10:00
parent f3f262574d
commit b01c516d59
No known key found for this signature in database
GPG key ID: F2216079B890CD57
4 changed files with 70 additions and 46 deletions

View file

@ -237,7 +237,10 @@ impl LanguageServer for RocServer {
let TextDocumentItem {
uri, text, version, ..
} = params.text_document;
self.change(uri, text, version).await;
let _res = unwind_async(self.change(uri, text, version)).await;
if let Err(e) = _res {
self.client.log_message(MessageType::ERROR, e.message).await
}
}
async fn did_change(&self, params: DidChangeTextDocumentParams) {
@ -251,7 +254,10 @@ impl LanguageServer for RocServer {
.last()
.expect("textDocument change event had no changes ");
self.change(uri, text, version).await;
let _res = unwind_async(self.change(uri, text, version)).await;
if let Err(e) = _res {
self.client.log_message(MessageType::ERROR, e.message).await
}
}
async fn did_close(&self, params: DidCloseTextDocumentParams) {
@ -359,6 +365,8 @@ async fn main() {
let stdout = tokio::io::stdout();
let (service, socket) = LspService::new(RocServer::new);
use roc_error_macros::set_panic_not_exit;
set_panic_not_exit(true);
Server::new(stdin, stdout, socket).serve(service).await;
}