From 640904adddb14eb002dfc8c94f8e4024a0ed804e Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Wed, 28 Jan 2026 17:49:22 +0100 Subject: [PATCH] fix: handle replacement completion ranges in Editor.replicate_selection --- src/tui/editor.zig | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/tui/editor.zig b/src/tui/editor.zig index ae73efb..43456f0 100644 --- a/src/tui/editor.zig +++ b/src/tui/editor.zig @@ -4901,16 +4901,17 @@ pub const Editor = struct { } fn replicate_selection(self: *Self, sel: Selection) void { - const dist = if (sel.begin.row != sel.end.row) - 0 - else if (sel.begin.col > sel.end.col) - sel.begin.col - sel.end.col - else - sel.end.col - sel.begin.col; + if (sel.begin.row != sel.end.row) return; + const primary = self.get_primary(); + const cursor = primary.cursor; + + const dist_begin = cursor.col - sel.begin.col; + const dist_end = sel.end.col - cursor.col; for (self.cursels.items) |*cursel_| if (cursel_.*) |*cursel| { var s = Selection.from_cursor(&cursel.cursor); - s.begin.col -|= dist; + s.begin.col -|= dist_begin; + s.end.col += dist_end; cursel.selection = s; }; }