@@ -46,10 +46,16 @@ fn jump_to_location(
4646 offset_encoding: OffsetEncoding,
4747 action: Action,
4848) {
49− let path = location
50− .uri
51− .to_file_path()
52− .expect("unable to convert URI to filepath");
49+ let path = match location.uri.to_file_path() {
50+ Ok(path) => path,
51+ Err(_) => {
52+ editor.set_error(format!(
53+ "unable to convert URI to filepath: {}",
54+ location.uri
55+ ));
56+ return;
57+ }
58+ };
5359 let _id = editor.open(path, action).expect("editor.open failed");
5460 let (view, doc) = current!(editor);
5561 let definition_pos = location.range.start;
@@ -344,9 +350,15 @@ pub fn apply_workspace_edit(
344350 workspace_edit: &lsp::WorkspaceEdit,
345351) {
346352 let mut apply_edits = |uri: &helix_lsp::Url, text_edits: Vec<lsp::TextEdit>| {
347− let path = uri
348− .to_file_path()
349− .expect("unable to convert URI to filepath");
353+ let path = match uri.to_file_path() {
354+ Ok(path) => path,
355+ Err(_) => {
356+ let err = format!("unable to convert URI to filepath: {}", uri);
357+ log::error!("{}", err);
358+ editor.set_error(err);
359+ return;
360+ }
361+ };
350362
351363 let current_view_id = view!(editor).id;
352364 let doc_id = editor.open(path, Action::Load).unwrap();
@@ -381,7 +393,7 @@ pub fn apply_workspace_edit(
381393 log::debug!("workspace changes: {:?}", changes);
382394 for (uri, text_edits) in changes {
383395 let text_edits = text_edits.to_vec();
384− apply_edits(uri, text_edits);
396+ apply_edits(uri, text_edits)
385397 }
386398 return;
387399 // Not sure if it works properly, it'll be safer to just panic here to avoid breaking some parts of code on which code actions will be used