Skip to content

Commit

Permalink
Avoid panics due to LSP connectivity issues (#617)
Browse files Browse the repository at this point in the history
* discard unsent LSP notifications

* close LSP event loops instead of panicking

* remove unnecessary close of aux loop

* remove event sender on send failure

* remove close handling on main loop

* Don't warn if no LSPs are connected

---------

Co-authored-by: Lionel Henry <[email protected]>
  • Loading branch information
jmcphers and lionel- authored Nov 7, 2024
1 parent b8505c5 commit 780e3a1
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions crates/ark/src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1733,9 +1733,12 @@ impl RMain {
RHelp::is_help_url(url, port)
}

fn send_lsp_notification(&self, event: KernelNotification) {
fn send_lsp_notification(&mut self, event: KernelNotification) {
if let Some(ref tx) = self.lsp_events_tx {
tx.send(Event::Kernel(event)).unwrap();
if let Err(err) = tx.send(Event::Kernel(event)) {
log::error!("Failed to send LSP notification: {err:?}");
self.lsp_events_tx = None;
}
}
}

Expand All @@ -1749,7 +1752,7 @@ impl RMain {
self.refresh_lsp();
}

pub fn refresh_lsp(&self) {
pub fn refresh_lsp(&mut self) {
match console_inputs() {
Ok(inputs) => {
self.send_lsp_notification(KernelNotification::DidChangeConsoleInputs(inputs));
Expand Down

0 comments on commit 780e3a1

Please sign in to comment.