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,
const empty: @This() = .{};
const pending: @This() = .empty;
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 {
self.data.deinit(allocator);
self.* = .empty;
@ -6285,10 +6291,14 @@ pub const Editor = struct {
pub fn completion(self: *Self, _: Context) Result {
const mv = tui.mainview() orelse return;
if (self.completions_request) |_|
self.completions_refresh_pending = true
else
self.completions_request = .pending;
const cursor = self.get_primary().cursor;
if (self.completions_request) |request| {
if (request.row != cursor.row or request.col != cursor.col)
self.completions_refresh_pending = true;
return;
} else {
self.completions_request = .pending(cursor.row, cursor.col);
}
if (!mv.is_any_panel_view_showing())
self.clamp_offset(mv.get_panel_height());
return self.pm_with_primary_cursor_pos(project_manager.completion);