Skip to content

Commit

Permalink
Jump to symbol ranges in LSP goto commands (helix-editor#5986)
Browse files Browse the repository at this point in the history
This follows prior changes like 42ad1a9: we select the range given
by the language server rather than the starting point.
  • Loading branch information
the-mikedavis authored and wes-adams committed Jul 3, 2023
1 parent 89155ad commit 0a4cdbe
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions helix-term/src/commands/lsp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit 0a4cdbe

Please sign in to comment.