From f18f6328bba8a5ea57955d31c69c9e115d0bb77a Mon Sep 17 00:00:00 2001 From: Tim Culverhouse Date: Mon, 18 Mar 2024 08:06:44 -0500 Subject: [PATCH] textinput: fix deleteToEnd Fix behavior of deleteToEnd to delete the character underneath the cursor to the end of the line. --- src/widgets/TextInput.zig | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/widgets/TextInput.zig b/src/widgets/TextInput.zig index 30e32a8..9098ed7 100644 --- a/src/widgets/TextInput.zig +++ b/src/widgets/TextInput.zig @@ -134,11 +134,9 @@ fn byteOffsetToCursor(self: TextInput) usize { } fn deleteToEnd(self: *TextInput) !void { - self.cursor_idx += 1; const offset = self.byteOffsetToCursor(); - try self.buf.replaceRangeAfter(offset, self.buf.realLength(), &.{}); + try self.buf.replaceRangeAfter(offset, self.buf.realLength() - offset, &.{}); self.grapheme_count = self.cursor_idx; - self.cursor_idx -= 1; } fn deleteToStart(self: *TextInput) !void {