fix: surround add overshoots end cursor on multi-row selections

This commit is contained in:
CJ van den Berg 2026-04-13 19:32:01 +02:00
parent 34d99a17d5
commit 16377e3700
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -907,8 +907,10 @@ fn surround_cursel_add(ed: *Editor, root: Buffer.Root, cursel: *CurSel, allocato
_, _, root_ = root_.insert_chars(end.row, end.col, enclose_pair.right, allocator, ed.metrics) catch return error.Stop; _, _, root_ = root_.insert_chars(end.row, end.col, enclose_pair.right, allocator, ed.metrics) catch return error.Stop;
_, _, root_ = root_.insert_chars(begin.row, begin.col, enclose_pair.left, allocator, ed.metrics) catch return error.Stop; _, _, root_ = root_.insert_chars(begin.row, begin.col, enclose_pair.left, allocator, ed.metrics) catch return error.Stop;
try end.move_right(root_, ed.metrics); if (begin.row == end.row) {
try end.move_right(root_, ed.metrics); try end.move_right(root_, ed.metrics); // for left-bracket column shift on same row
}
try end.move_right(root_, ed.metrics); // skip past right bracket
cursel.selection = Selection{ .begin = begin, .end = end }; cursel.selection = Selection{ .begin = begin, .end = end };
ed.nudge_insert(.{ .begin = begin, .end = end }, cursel, encloser.len * 2); ed.nudge_insert(.{ .begin = begin, .end = end }, cursel, encloser.len * 2);