diff --git a/src/keybind/builtin/helix.json b/src/keybind/builtin/helix.json index ffec1f2..728d827 100644 --- a/src/keybind/builtin/helix.json +++ b/src/keybind/builtin/helix.json @@ -146,8 +146,8 @@ ["a", ["move_right"], ["enter_mode", "insert"]], ["o", ["smart_insert_line_after"], ["enter_mode", "insert"]], - ["d", "cut_forward_internal"], - ["c", ["cut_forward_internal"], ["enter_mode", "insert"]], + ["d", "cut_forward_internal_inclusive"], + ["c", ["cut_forward_internal_inclusive"], ["enter_mode", "insert"]], ["s", "select_regex"], [";", "collapse_selections"], diff --git a/src/tui/editor.zig b/src/tui/editor.zig index 7a439d4..ada0f81 100644 --- a/src/tui/editor.zig +++ b/src/tui/editor.zig @@ -2495,14 +2495,7 @@ pub const Editor = struct { continue; } - switch (tui.get_selection_style()) { - .inclusive => { - const sel = try cursel.enable_selection(root, self.metrics); - cursel.cursor = sel.end; - cursel.check_selection(root, self.metrics); - }, - else => with_selection_const(root, move, cursel, self.metrics) catch continue, - } + with_selection_const(root, move, cursel, self.metrics) catch continue; const cut_text, root = self.cut_selection(root, cursel) catch continue; if (first) { diff --git a/src/tui/mode/helix.zig b/src/tui/mode/helix.zig index f4efddb..85e15e2 100644 --- a/src/tui/mode/helix.zig +++ b/src/tui/mode/helix.zig @@ -124,6 +124,17 @@ const cmds_ = struct { ed.clamp(); } pub const move_prev_word_start_meta: Meta = .{ .description = "Move previous word start" }; + + pub fn cut_forward_internal_inclusive(_: *void, _: Ctx) Result { + const mv = tui.mainview() orelse return; + const ed = mv.get_active_editor() orelse return; + const b = try ed.buf_for_update(); + const text, const root = try ed.cut_to(move_noop, b.root); + ed.set_clipboard_internal(text); + try ed.update_buf(root); + ed.clamp(); + } + pub const cut_forward_internal_inclusive_meta: Meta = .{ .description = "Cut next character to internal clipboard (inclusive)" }; }; fn move_cursor_word_left_helix(root: Buffer.Root, cursor: *Cursor, metrics: Buffer.Metrics) error{Stop}!void { @@ -148,3 +159,5 @@ fn move_cursor_word_left_helix(root: Buffer.Root, cursor: *Cursor, metrics: Buff try move_cursor_word_left_helix(root, cursor, metrics); } } + +fn move_noop(_: Buffer.Root, _: *Cursor, _: Buffer.Metrics) error{Stop}!void {}