mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-29 06:23:25 +00:00
Fix signature help LSP offset conversion
This commit is contained in:
parent
ee2cbe0ae8
commit
5ee028bbb8
1 changed files with 7 additions and 3 deletions
|
@ -358,7 +358,11 @@ pub(crate) fn signature_help(
|
||||||
let params = call_info
|
let params = call_info
|
||||||
.parameter_ranges()
|
.parameter_ranges()
|
||||||
.iter()
|
.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 {
|
.map(|label_offsets| lsp_types::ParameterInformation {
|
||||||
label: lsp_types::ParameterLabel::LabelOffsets(label_offsets),
|
label: lsp_types::ParameterLabel::LabelOffsets(label_offsets),
|
||||||
documentation: None,
|
documentation: None,
|
||||||
|
@ -375,9 +379,9 @@ pub(crate) fn signature_help(
|
||||||
label.push_str(", ");
|
label.push_str(", ");
|
||||||
}
|
}
|
||||||
first = false;
|
first = false;
|
||||||
let start = label.len() as u32;
|
let start = label.chars().count() as u32;
|
||||||
label.push_str(param);
|
label.push_str(param);
|
||||||
let end = label.len() as u32;
|
let end = label.chars().count() as u32;
|
||||||
params.push(lsp_types::ParameterInformation {
|
params.push(lsp_types::ParameterInformation {
|
||||||
label: lsp_types::ParameterLabel::LabelOffsets([start, end]),
|
label: lsp_types::ParameterLabel::LabelOffsets([start, end]),
|
||||||
documentation: None,
|
documentation: None,
|
||||||
|
|
Loading…
Reference in a new issue