@@ -2445,7 +2445,7 @@ fn apply_workspace_edit(
2446 if let Some(ref changes) = workspace_edit.changes {
2446 if let Some(ref changes) = workspace_edit.changes {
2447 log::debug!("workspace changes: {:?}", changes);
2447 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"));
2450 // 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
2450 // 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
2451 // TODO: find some example that uses workspace changes, and test it
2451 // TODO: find some example that uses workspace changes, and test it
@@ -2463,8 +2463,30 @@ fn apply_workspace_edit(
2463 match document_changes {
2463 match document_changes {
2464 lsp::DocumentChanges::Edits(document_edits) => {
2464 lsp::DocumentChanges::Edits(document_edits) => {
2465 for document_edit in document_edits {
2465 for document_edit in document_edits {
2466− let (view, doc) = current!(editor);
2466+ let path = document_edit
2467− assert_eq!(doc.url().unwrap(), document_edit.text_document.uri);
2467+ .text_document
2470+ .expect("unable to convert URI to filepath");
2471+ let current_view_id = view!(editor).id;
2473+ .document_by_path_mut(path)
2474+ .expect("Document for document_changes not found");
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
2482+ // Hack: we take the first available view_id
2487+ .expect("No view_id available")
2468 let edits = document_edit
2490 let edits = document_edit
@@ -2482,8 +2504,8 @@ fn apply_workspace_edit(
2483 offset_encoding,
2505 offset_encoding,
2485− doc.apply(&transaction, view.id);
2507+ doc.apply(&transaction, view_id);
2486− doc.append_changes_to_history(view.id);
2508+ doc.append_changes_to_history(view_id);
2489 lsp::DocumentChanges::Operations(operations) => {
2511 lsp::DocumentChanges::Operations(operations) => {