refactor: add support for backspace during completion

This commit is contained in:
CJ van den Berg 2025-12-23 23:53:14 +01:00
parent b2996cddbd
commit 911fc3160a
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
3 changed files with 22 additions and 3 deletions

View file

@ -110,7 +110,10 @@ pub fn update_query(self: *Type, query: []const u8) void {
const primary = editor.get_primary();
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;
const root_ = if (query.len > 0)
editor.insert(b.root, primary, query, b.allocator) catch return
else
editor.delete_selection(b.root, primary, b.allocator) catch return;
self.value.cursor = editor.get_primary().cursor;
if (self.value.replace) |*sel| sel.* = .{ .begin = sel.begin, .end = self.value.cursor };
primary.selection = null;