fix: preserve cursor column and target in delete_line

This is the expected behaviour (for me at least) and makes delete_line
significantly more useful than plain `cut` with no selection.

closes #342
This commit is contained in:
CJ van den Berg 2025-10-30 11:38:50 +01:00
parent e42f3ff3a5
commit 4087e0a3f9

View file

@ -3019,8 +3019,13 @@ pub const Editor = struct {
const b = try self.buf_for_update();
var root = b.root;
for (self.cursels.items) |*cursel_| if (cursel_.*) |*cursel| {
const col = cursel.cursor.col;
const target = cursel.cursor.target;
try self.select_line_at_cursor(root, cursel, .include_eol);
root = try self.delete_selection(root, cursel, b.allocator);
cursel.cursor.col = col;
cursel.cursor.target = target;
cursel.cursor.clamp_to_buffer(root, self.metrics);
};
try self.update_buf(root);
self.clamp();