refactor: move cut_to helix workaround to a helix specific command
This commit is contained in:
parent
62c6313107
commit
563eb57e44
3 changed files with 16 additions and 10 deletions
|
@ -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"],
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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 {}
|
||||
|
|
Loading…
Add table
Reference in a new issue