on master help sign in
Fix byte index error in signature help highlighting
a8b123fGokul Soumya
helix-term/src/commands/lsp.rs+6−1
@@ -904,7 +904,12 @@ pub fn signature_help_impl(cx: &mut Context, invoked: SignatureHelpInvoked) {
904 Some((start, start + string.len()))
904 Some((start, start + string.len()))
905 }
905 }
906 lsp::ParameterLabel::LabelOffsets([start, end]) => {
906 lsp::ParameterLabel::LabelOffsets([start, end]) => {
907− Some((*start as usize, *end as usize))
907+ // LS sends offsets based on utf-16 based string representation
908+ // but highlighting in helix is done using byte offset.
909+ use helix_core::str_utils::char_to_byte_idx;
910+ let from = char_to_byte_idx(&signature.label, *start as usize);
911+ let to = char_to_byte_idx(&signature.label, *end as usize);
912+ Some((from, to))
908 }
913 }
909 }
914 }
910 };
915 };