fix: clamp cursor with panel offset before completion

This commit is contained in:
CJ van den Berg 2025-12-26 22:48:59 +01:00
parent fc50a4ebcd
commit 34a41e72f8
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -6013,11 +6013,14 @@ pub const Editor = struct {
pub const references_meta: Meta = .{ .description = "Language: Find all references" }; pub const references_meta: Meta = .{ .description = "Language: Find all references" };
pub fn completion(self: *Self, _: Context) Result { pub fn completion(self: *Self, _: Context) Result {
const mv = tui.mainview() orelse return;
const file_path = self.file_path orelse return; const file_path = self.file_path orelse return;
const root = self.buf_root() catch return; const root = self.buf_root() catch return;
const primary = self.get_primary(); const primary = self.get_primary();
const col = try root.get_line_width_to_pos(primary.cursor.row, primary.cursor.col, self.metrics); const col = try root.get_line_width_to_pos(primary.cursor.row, primary.cursor.col, self.metrics);
self.completions.clearRetainingCapacity(); self.completions.clearRetainingCapacity();
if (!mv.is_any_panel_view_showing())
self.clamp_offset(mv.get_panel_height());
return project_manager.completion(file_path, primary.cursor.row, col); return project_manager.completion(file_path, primary.cursor.row, col);
} }
pub const completion_meta: Meta = .{ .description = "Language: Show completions at cursor" }; pub const completion_meta: Meta = .{ .description = "Language: Show completions at cursor" };