@@ -2445,7 +2445,7 @@ fn apply_workspace_edit(
24452445) {
24462446 if let Some(ref changes) = workspace_edit.changes {
24472447 log::debug!("workspace changes: {:?}", changes);
2448− editor.set_error(String::from("Handling workspace changesis not implemented yet, see https://github.com/helix-editor/helix/issues/183"));
2448+ editor.set_error(String::from("Handling workspace_edit.changes is not implemented yet, see https://github.com/helix-editor/helix/issues/183"));
24492449 return;
24502450 // 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
24512451 // TODO: find some example that uses workspace changes, and test it
@@ -2463,8 +2463,30 @@ fn apply_workspace_edit(
24632463 match document_changes {
24642464 lsp::DocumentChanges::Edits(document_edits) => {
24652465 for document_edit in document_edits {
2466− let (view, doc) = current!(editor);
2467− assert_eq!(doc.url().unwrap(), document_edit.text_document.uri);
2466+ let path = document_edit
2467+ .text_document
2468+ .uri
2469+ .to_file_path()
2470+ .expect("unable to convert URI to filepath");
2471+ let current_view_id = view!(editor).id;
2472+ let doc = editor
2473+ .document_by_path_mut(path)
2474+ .expect("Document for document_changes not found");
2475+
2476+ // Need to determine a view for apply/append_changes_to_history
2477+ let selections = doc.selections();
2478+ let view_id = if selections.contains_key(¤t_view_id) {
2479+ // use current if possible
2480+ current_view_id
2481+ } else {
2482+ // Hack: we take the first available view_id
2483+ selections
2484+ .keys()
2485+ .next()
2486+ .copied()
2487+ .expect("No view_id available")
2488+ };
2489+
24682490 let edits = document_edit
24692491 .edits
24702492 .iter()
@@ -2482,8 +2504,8 @@ fn apply_workspace_edit(
24822504 edits,
24832505 offset_encoding,
24842506 );
2485− doc.apply(&transaction, view.id);
2486− doc.append_changes_to_history(view.id);
2507+ doc.apply(&transaction, view_id);
2508+ doc.append_changes_to_history(view_id);
24872509 }
24882510 }
24892511 lsp::DocumentChanges::Operations(operations) => {