Unnamed repository; edit this file 'description' to name the repository.
| -rw-r--r-- | crates/rust-analyzer/src/lsp/to_proto.rs | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/crates/rust-analyzer/src/lsp/to_proto.rs b/crates/rust-analyzer/src/lsp/to_proto.rs index cd384ca713..04b2003306 100644 --- a/crates/rust-analyzer/src/lsp/to_proto.rs +++ b/crates/rust-analyzer/src/lsp/to_proto.rs @@ -496,8 +496,15 @@ pub(crate) fn signature_help( .parameter_ranges() .iter() .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; + let start = call_info.signature[..it.start().into()] + .chars() + .map(|c| c.len_utf16()) + .sum::<usize>() as u32; + let end = start + + call_info.signature[it.start().into()..it.end().into()] + .chars() + .map(|c| c.len_utf16()) + .sum::<usize>() as u32; [start, end] }) .map(|label_offsets| lsp_types::ParameterInformation { @@ -516,9 +523,9 @@ pub(crate) fn signature_help( label.push_str(", "); } first = false; - let start = label.chars().count() as u32; + let start = label.len() as u32; label.push_str(param); - let end = label.chars().count() as u32; + let end = label.len() as u32; params.push(lsp_types::ParameterInformation { label: lsp_types::ParameterLabel::LabelOffsets([start, end]), documentation: None, |