Skip to content

Commit

Permalink
textinput: fix deleteToEnd
Browse files Browse the repository at this point in the history
Fix behavior of deleteToEnd to delete the character underneath the
cursor to the end of the line.
  • Loading branch information
rockorager committed Mar 18, 2024
1 parent 8e76610 commit f18f632
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/widgets/TextInput.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit f18f632

Please sign in to comment.