Skip to content

Commit 5ee028b

Browse files
author
Jonas Schievink
committed
Fix signature help LSP offset conversion
1 parent ee2cbe0 commit 5ee028b

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

crates/rust-analyzer/src/to_proto.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,11 @@ pub(crate) fn signature_help(
358358
let params = call_info
359359
.parameter_ranges()
360360
.iter()
361-
.map(|it| [u32::from(it.start()), u32::from(it.end())])
361+
.map(|it| {
362+
let start = call_info.signature[..it.start().into()].chars().count() as u32;
363+
let end = call_info.signature[..it.end().into()].chars().count() as u32;
364+
[start, end]
365+
})
362366
.map(|label_offsets| lsp_types::ParameterInformation {
363367
label: lsp_types::ParameterLabel::LabelOffsets(label_offsets),
364368
documentation: None,
@@ -375,9 +379,9 @@ pub(crate) fn signature_help(
375379
label.push_str(", ");
376380
}
377381
first = false;
378-
let start = label.len() as u32;
382+
let start = label.chars().count() as u32;
379383
label.push_str(param);
380-
let end = label.len() as u32;
384+
let end = label.chars().count() as u32;
381385
params.push(lsp_types::ParameterInformation {
382386
label: lsp_types::ParameterLabel::LabelOffsets([start, end]),
383387
documentation: None,

0 commit comments

Comments
 (0)