summaryrefslogtreecommitdiff
path: root/src/Text.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/Text.zig')
-rw-r--r--src/Text.zig5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/Text.zig b/src/Text.zig
index cef76b3b..88630f83 100644
--- a/src/Text.zig
+++ b/src/Text.zig
@@ -182,7 +182,10 @@ pub fn primaryRange(t: *Text, text: []const u8, row0: i32) modal.Selection {
const e = if (r1 + 1 >= modal.cursorLineCount(text)) text.len else modal.lineStartOffset(text, r1 + 1);
return .{ .anchor = s, .head = @max(e, modal.nextGrapheme(text, c)) };
}
- if (t.vsel.active) return cellRange(text, t.vsel.row - row0, t.vsel.col, t.cur_row - row0, t.cur_col);
+ // Both ends through the line index, as the cursor's: cellRange counts
+ // lines from the top for each, a pass over a big file per call (the
+ // places' settle and every insert-mode key asked it).
+ if (t.vsel.active) return cellOffRange(text, File.textOffset(t, text, .{ .row = @intCast(@max(0, t.vsel.row - row0)), .col = @intCast(@max(0, t.vsel.col)) }), c);
return .{ .anchor = c, .head = modal.nextGrapheme(text, c) };
}