From 84e24b33dcda16d1d64805f34dcc02d82d0de8f1 Mon Sep 17 00:00:00 2001 From: Gabriel Dinner-David Date: Mon, 8 Jan 2024 20:21:16 -0500 Subject: make sure to sync views when applying edits to unfocused views (#9173) --- helix-term/src/commands/lsp.rs | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) (limited to 'helix-term/src/commands/lsp.rs') diff --git a/helix-term/src/commands/lsp.rs b/helix-term/src/commands/lsp.rs index 34ffa529..0096e6aa 100644 --- a/helix-term/src/commands/lsp.rs +++ b/helix-term/src/commands/lsp.rs @@ -896,7 +896,6 @@ pub fn apply_workspace_edit( } }; - let current_view_id = view!(editor).id; let doc_id = match editor.open(&path, Action::Load) { Ok(doc_id) => doc_id, Err(err) => { @@ -907,7 +906,7 @@ pub fn apply_workspace_edit( } }; - let doc = doc_mut!(editor, &doc_id); + let doc = doc!(editor, &doc_id); if let Some(version) = version { if version != doc.version() { let err = format!("outdated workspace edit for {path:?}"); @@ -918,18 +917,8 @@ pub fn apply_workspace_edit( } // Need to determine a view for apply/append_changes_to_history - let selections = doc.selections(); - let view_id = if selections.contains_key(¤t_view_id) { - // use current if possible - current_view_id - } else { - // Hack: we take the first available view_id - selections - .keys() - .next() - .copied() - .expect("No view_id available") - }; + let view_id = editor.get_synced_view_id(doc_id); + let doc = doc_mut!(editor, &doc_id); let transaction = helix_lsp::util::generate_transaction_from_edits( doc.text(), -- cgit v1.2.3-70-g09d2