fix: hover should convert column to byte position in LSP response

closes: #85
This commit is contained in:
CJ van den Berg 2024-12-20 20:16:50 +01:00
parent 1aa64b8ea4
commit 69c2d06007
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
2 changed files with 31 additions and 21 deletions

View file

@ -3980,6 +3980,30 @@ pub const Editor = struct {
return project_manager.hover(file_path, row, pos);
}
pub fn add_hover_highlight(self: *Self, match_: Match) void {
const root = self.buf_root() catch return;
const match: Match = .{
.begin = .{
.row = match_.begin.row,
.col = root.pos_to_width(match_.begin.row, match_.begin.col, self.metrics) catch return,
},
.end = .{
.row = match_.end.row,
.col = root.pos_to_width(match_.end.row, match_.end.col, self.metrics) catch return,
},
};
switch (self.matches.items.len) {
0 => {
(self.matches.addOne() catch return).* = match;
},
1 => {
self.matches.items[0] = match;
},
else => {},
}
self.need_render();
}
pub fn add_diagnostic(
self: *Self,
file_path: []const u8,