Skip to content

Commit

Permalink
Fix signature help LSP offset conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonas Schievink committed May 16, 2022
1 parent ee2cbe0 commit 5ee028b
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions crates/rust-analyzer/src/to_proto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,11 @@ pub(crate) fn signature_help(
let params = call_info
.parameter_ranges()
.iter()
.map(|it| [u32::from(it.start()), u32::from(it.end())])
.map(|it| {
let start = call_info.signature[..it.start().into()].chars().count() as u32;
let end = call_info.signature[..it.end().into()].chars().count() as u32;
[start, end]
})
.map(|label_offsets| lsp_types::ParameterInformation {
label: lsp_types::ParameterLabel::LabelOffsets(label_offsets),
documentation: None,
Expand All @@ -375,9 +379,9 @@ pub(crate) fn signature_help(
label.push_str(", ");
}
first = false;
let start = label.len() as u32;
let start = label.chars().count() as u32;
label.push_str(param);
let end = label.len() as u32;
let end = label.chars().count() as u32;
params.push(lsp_types::ParameterInformation {
label: lsp_types::ParameterLabel::LabelOffsets([start, end]),
documentation: None,
Expand Down

0 comments on commit 5ee028b

Please sign in to comment.