fix: replace full completion item correctly in completion_dropdown

This commit is contained in:
CJ van den Berg 2025-12-18 22:30:48 +01:00
parent 394eb5405f
commit 8c9146a1c5
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -108,8 +108,9 @@ pub fn update_query(self: *Type, query: []const u8) void {
primary.selection = get_insert_selection(self, editor.get_primary().cursor);
const b = editor.buf_for_update() catch return;
const root_ = editor.insert(b.root, primary, query, b.allocator) catch return;
primary.selection = null;
self.value.cursor = editor.get_primary().cursor;
if (self.value.replace) |*sel| sel.* = .{ .begin = sel.begin, .end = self.value.cursor };
primary.selection = null;
editor.update_buf(root_) catch {};
editor.clamp();
editor.need_render();
@ -117,13 +118,12 @@ pub fn update_query(self: *Type, query: []const u8) void {
}
fn get_insert_selection(self: *Type, cursor: ed.Cursor) ed.Selection {
const begin = if (self.value.replace) |sel|
sel.begin
return if (self.value.replace) |sel|
sel
else if (self.value.start.selection) |sel|
sel.begin
sel
else
self.value.start.cursor;
return .{ .begin = begin, .end = cursor };
.{ .begin = self.value.start.cursor, .end = cursor };
}
pub fn clear_entries(self: *Type) void {