Fix inlay hints not resolving correct position
This commit is contained in:
parent
637f46a961
commit
cf6ec12afb
3 changed files with 9 additions and 2 deletions
|
@ -271,7 +271,7 @@ impl RegexRule for ScriptRule {
|
||||||
let range = matches
|
let range = matches
|
||||||
.get(0)
|
.get(0)
|
||||||
.map(|m| {
|
.map(|m| {
|
||||||
if token.source().content().as_bytes()[m.start()] == b'\n' {
|
if index == 0 && token.source().content().as_bytes()[m.start()] == b'\n' {
|
||||||
m.start() + 1..m.end()
|
m.start() + 1..m.end()
|
||||||
} else {
|
} else {
|
||||||
m.range()
|
m.range()
|
||||||
|
@ -295,6 +295,7 @@ impl RegexRule for ScriptRule {
|
||||||
}
|
}
|
||||||
sems.add(matches.get(3).unwrap().range(), tokens.script_content);
|
sems.add(matches.get(3).unwrap().range(), tokens.script_content);
|
||||||
}
|
}
|
||||||
|
eprintln!("range={:#?}", range);
|
||||||
sems.add(range.end - 2..range.end, tokens.script_sep);
|
sems.add(range.end - 2..range.end, tokens.script_sep);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -306,7 +307,7 @@ impl RegexRule for ScriptRule {
|
||||||
});
|
});
|
||||||
if !label.is_empty() {
|
if !label.is_empty() {
|
||||||
label.pop();
|
label.pop();
|
||||||
hints.add(matches.get(0).unwrap().end(), label);
|
hints.add(matches.get(0).unwrap().end() - 1, label);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ use tower_lsp::lsp_types::InlayHint;
|
||||||
use crate::parser::source::LineCursor;
|
use crate::parser::source::LineCursor;
|
||||||
use crate::parser::source::Source;
|
use crate::parser::source::Source;
|
||||||
use crate::parser::source::SourceFile;
|
use crate::parser::source::SourceFile;
|
||||||
|
use crate::parser::source::SourcePosition;
|
||||||
use crate::parser::source::VirtualSource;
|
use crate::parser::source::VirtualSource;
|
||||||
|
|
||||||
use super::data::LSPData;
|
use super::data::LSPData;
|
||||||
|
@ -82,6 +83,7 @@ impl<'a> Hints<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn add(&self, position: usize, label: String) {
|
pub fn add(&self, position: usize, label: String) {
|
||||||
|
let position = self.original_source.original_position(position).1;
|
||||||
let mut cursor = self.hints.cursor.borrow_mut();
|
let mut cursor = self.hints.cursor.borrow_mut();
|
||||||
cursor.move_to(position);
|
cursor.move_to(position);
|
||||||
|
|
||||||
|
|
|
@ -435,6 +435,10 @@ impl<'a> Semantics<'a> {
|
||||||
/// Add a semantic token to be processed instantly
|
/// Add a semantic token to be processed instantly
|
||||||
pub fn add(&self, range: Range<usize>, token: (u32, u32)) {
|
pub fn add(&self, range: Range<usize>, token: (u32, u32)) {
|
||||||
let range = self.original_source.original_range(range).1;
|
let range = self.original_source.original_range(range).1;
|
||||||
|
eprintln!(
|
||||||
|
"Added {token:#?} range={range:#?} source={:#?}",
|
||||||
|
self.original_source
|
||||||
|
);
|
||||||
self.process_queue(range.start);
|
self.process_queue(range.start);
|
||||||
self.add_impl(range, token);
|
self.add_impl(range, token);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue