diff options
author | Michael Davis | 2023-03-08 01:51:29 +0000 |
---|---|---|
committer | GitHub | 2023-03-08 01:51:29 +0000 |
commit | 6dc017b9e23be4f9331bfac8d10f39cdfa54e7bd (patch) | |
tree | 300799686ef43bb68f8ebe9d3aa658b5a7815566 /helix-term/src/commands | |
parent | 170593161cb23edc433d937eb62a9b8fd76bd339 (diff) |
Jump to symbol ranges in LSP goto commands (#5986)
This follows prior changes like 42ad1a9e: we select the range given
by the language server rather than the starting point.
Diffstat (limited to 'helix-term/src/commands')
-rw-r--r-- | helix-term/src/commands/lsp.rs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/helix-term/src/commands/lsp.rs b/helix-term/src/commands/lsp.rs index 3b94c9bd..d59eebdb 100644 --- a/helix-term/src/commands/lsp.rs +++ b/helix-term/src/commands/lsp.rs @@ -5,7 +5,7 @@ use helix_lsp::{ self, CodeAction, CodeActionOrCommand, CodeActionTriggerKind, DiagnosticSeverity, NumberOrString, }, - util::{diagnostic_to_lsp_diagnostic, lsp_pos_to_pos, lsp_range_to_range, range_to_lsp_range}, + util::{diagnostic_to_lsp_diagnostic, lsp_range_to_range, range_to_lsp_range}, OffsetEncoding, }; use tui::{ @@ -196,15 +196,15 @@ fn jump_to_location( } } let (view, doc) = current!(editor); - let definition_pos = location.range.start; // TODO: convert inside server - let new_pos = if let Some(new_pos) = lsp_pos_to_pos(doc.text(), definition_pos, offset_encoding) - { - new_pos - } else { - return; - }; - doc.set_selection(view.id, Selection::point(new_pos)); + let new_range = + if let Some(new_range) = lsp_range_to_range(doc.text(), location.range, offset_encoding) { + new_range + } else { + log::warn!("lsp position out of bounds - {:?}", location.range); + return; + }; + doc.set_selection(view.id, Selection::single(new_range.anchor, new_range.head)); align_view(doc, view, Align::Center); } |