Skip to content

Commit

Permalink
Prevent .unwrap() on Err
Browse files Browse the repository at this point in the history
  • Loading branch information
helgemahrt committed Dec 15, 2024
1 parent 16f6cf0 commit 07d3f56
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions crates/project/src/lsp_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1943,8 +1943,9 @@ impl LocalLspStore {
Some(local) => local.abs_path(cx),
None => return,
};
let file_url = lsp::Url::from_file_path(old_path).unwrap();
if let Ok(file_url) = lsp::Url::from_file_path(old_path) {
self.unregister_buffer_from_language_servers(buffer, file_url, cx);
}
}

pub(crate) fn unregister_buffer_from_language_servers(
Expand Down Expand Up @@ -4906,7 +4907,7 @@ impl LspStore {
let buffer = buffer.read(cx);
let file = File::from_dyn(buffer.file())?;
let abs_path = file.as_local()?.abs_path(cx);
let uri = lsp::Url::from_file_path(abs_path).unwrap();
if let Ok(uri) = lsp::Url::from_file_path(abs_path) {
let next_snapshot = buffer.text_snapshot();

let language_servers: Vec<_> = self
Expand Down Expand Up @@ -4997,6 +4998,7 @@ impl LspStore {
)
.log_err();
}
}

None
}
Expand Down

0 comments on commit 07d3f56

Please sign in to comment.