From 601a5c8a31aaa6c2ce7f20ae7150b1da1ac80e01 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 4 Nov 2026 23:16:01 -0300 Subject: Text, normal, modal: the last f/F/t/T is kept as its Find kind (find_op: ?Find), not as the config character that bound it, and findMove and findTarget take the kind instead of two bools; Text's walked shape changes, so a client and a daemon from either side of this change refuse each other (wire semantics) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- src/modal.zig | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'src/modal.zig') diff --git a/src/modal.zig b/src/modal.zig index 0054afeb..0a61e920 100644 --- a/src/modal.zig +++ b/src/modal.zig @@ -1659,9 +1659,10 @@ pub fn moveParagraph(text: []const u8, r: Selection, count: usize, fwd: bool, ex /// f/F/t/T target cell. helix find_char: the exclusive (till) search starts /// one further out so repeats make progress; not-found = null (no move). -pub fn findTarget(text: []const u8, cursor: usize, ch: u21, fwd: bool, till: bool, count: usize) ?usize { +pub fn findTarget(text: []const u8, cursor: usize, ch: u21, kind: Normal.Find, count: usize) ?usize { + const till = kind == .till_forward or kind == .till_backward; var left = @max(1, count); - if (fwd) { + if (kind == .forward or kind == .till_forward) { const head = nextGrapheme(text, cursor); var i = if (till) nextGrapheme(text, head) else head; if (i > text.len) return null; @@ -1906,14 +1907,14 @@ test "paragraph selections cross blank lines" { test "find targets count matches and skip adjacent till targets" { const t = "abcabc\n"; - try std.testing.expectEqual(@as(usize, 2), findTarget(t, 0, 'c', true, false, 1).?); - try std.testing.expectEqual(@as(usize, 5), findTarget(t, 0, 'c', true, false, 2).?); - try std.testing.expectEqual(@as(usize, 1), findTarget(t, 0, 'c', true, true, 1).?); + try std.testing.expectEqual(@as(usize, 2), findTarget(t, 0, 'c', .forward, 1).?); + try std.testing.expectEqual(@as(usize, 5), findTarget(t, 0, 'c', .forward, 2).?); + try std.testing.expectEqual(@as(usize, 1), findTarget(t, 0, 'c', .till_forward, 1).?); // till repeat skips the adjacent target: from cell 1, next tc reaches 4 - try std.testing.expectEqual(@as(usize, 4), findTarget(t, 1, 'c', true, true, 1).?); - try std.testing.expectEqual(@as(usize, 3), findTarget(t, 5, 'a', false, false, 1).?); - try std.testing.expectEqual(@as(usize, 4), findTarget(t, 5, 'a', false, true, 1).?); - try std.testing.expectEqual(@as(?usize, null), findTarget(t, 0, 'z', true, false, 1)); + try std.testing.expectEqual(@as(usize, 4), findTarget(t, 1, 'c', .till_forward, 1).?); + try std.testing.expectEqual(@as(usize, 3), findTarget(t, 5, 'a', .backward, 1).?); + try std.testing.expectEqual(@as(usize, 4), findTarget(t, 5, 'a', .till_backward, 1).?); + try std.testing.expectEqual(@as(?usize, null), findTarget(t, 0, 'z', .forward, 1)); } test "extended grapheme boundaries cover combining emoji flag and CJK text" { @@ -2016,7 +2017,7 @@ test "GB3 keeps CR-LF one cluster for every grapheme step" { } test "Unicode find and word motion stay on grapheme boundaries" { - try std.testing.expectEqual(@as(usize, 3), findTarget("\u{e9}x\u{e9}", 0, 'é', true, false, 1).?); + try std.testing.expectEqual(@as(usize, 3), findTarget("\u{e9}x\u{e9}", 0, 'é', .forward, 1).?); const text = "café 世界 ok\n"; const first = moveWord(text, .{ .anchor = 0, .head = 1 }, 1, .next_word_start); -- cgit v1.3