fix: do not set completion refresh pending for duplicate requests

This commit is contained in:
CJ van den Berg 2026-02-03 14:46:12 +01:00
parent f590d7cec8
commit 8767dc9dc1
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -440,9 +440,15 @@ pub const Editor = struct {
is_complete: bool = true, is_complete: bool = true,
const empty: @This() = .{}; const empty: @This() = .{};
const pending: @This() = .empty;
const done: ?@This() = null; const done: ?@This() = null;
fn pending(row: usize, col: usize) @This() {
return .{
.row = row,
.col = col,
};
}
fn deinit(self: *@This(), allocator: std.mem.Allocator) void { fn deinit(self: *@This(), allocator: std.mem.Allocator) void {
self.data.deinit(allocator); self.data.deinit(allocator);
self.* = .empty; self.* = .empty;
@ -6285,10 +6291,14 @@ pub const Editor = struct {
pub fn completion(self: *Self, _: Context) Result { pub fn completion(self: *Self, _: Context) Result {
const mv = tui.mainview() orelse return; const mv = tui.mainview() orelse return;
if (self.completions_request) |_| const cursor = self.get_primary().cursor;
self.completions_refresh_pending = true if (self.completions_request) |request| {
else if (request.row != cursor.row or request.col != cursor.col)
self.completions_request = .pending; self.completions_refresh_pending = true;
return;
} else {
self.completions_request = .pending(cursor.row, cursor.col);
}
if (!mv.is_any_panel_view_showing()) if (!mv.is_any_panel_view_showing())
self.clamp_offset(mv.get_panel_height()); self.clamp_offset(mv.get_panel_height());
return self.pm_with_primary_cursor_pos(project_manager.completion); return self.pm_with_primary_cursor_pos(project_manager.completion);