Skip to content

Commit 3b14843

Browse files
committed
Try Fix emmylua check :highlighting is often wrong
1 parent 1aa9c47 commit 3b14843

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

crates/emmylua_code_analysis/src/vfs/document.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,19 @@ impl<'a> LuaDocument<'a> {
137137
}
138138

139139
pub fn get_range_span(&self, range: lsp_types::Range) -> Option<(usize, usize)> {
140+
let text = self.get_text();
140141
let start = self.get_offset(range.start.line as usize, range.start.character as usize)?;
141142
let end = self.get_offset(range.end.line as usize, range.end.character as usize)?;
143+
// char count
144+
let start = text
145+
.get(..start.into())
146+
.map(|s| s.chars().count())
147+
.unwrap_or(0);
148+
let end = text
149+
.get(..end.into())
150+
.map(|s| s.chars().count())
151+
.unwrap_or(0);
152+
142153
Some((start.into(), end.into()))
143154
}
144155
}

0 commit comments

Comments
 (0)