diff --git a/src/keybind/builtin/flow.json b/src/keybind/builtin/flow.json index 4edfb38..1fa0af2 100644 --- a/src/keybind/builtin/flow.json +++ b/src/keybind/builtin/flow.json @@ -25,6 +25,7 @@ ["alt+x", "open_command_palette"], ["f4", "toggle_input_mode"], ["ctrl+f2", "insert_command_name"], + ["ctrl+k ctrl+s", "insert_command_name"], ["f9", "theme_prev"], ["f10", "theme_next"], ["f11", "toggle_panel"], @@ -168,8 +169,6 @@ ["alt+}", "shrink_selection", true], ["alt+[", "select_prev_sibling", true], ["alt+]", "select_next_sibling", true], - ["alt+shift+e", "move_parent_node_end"], - ["alt+shift+b", "move_parent_node_start"], ["alt+a", "select_all_siblings"], ["alt+shift+home", "move_scroll_left"], ["alt+shift+end", "move_scroll_right"], @@ -202,6 +201,7 @@ ["shift+enter", "smart_insert_line_before"], ["shift+backspace", "delete_backward"], ["ctrl+shift+k", "delete_line"], + ["alt+shift+e", "select_line"], ["shift+tab", "unindent"], ["f2", "rename_symbol"], ["f3", "goto_next_match"], diff --git a/src/tui/editor.zig b/src/tui/editor.zig index 948ac8b..f23cda4 100644 --- a/src/tui/editor.zig +++ b/src/tui/editor.zig @@ -3015,22 +3015,55 @@ pub const Editor = struct { } pub const delete_to_end_meta: Meta = .{ .description = "Delete to end of line" }; - pub fn delete_line(self: *Self, _: Context) Result { + pub fn select_line(self: *Self, ctx: Context) Result { + const root = try self.buf_root(); + var repeat: usize = 1; + _ = ctx.args.match(.{tp.extract(&repeat)}) catch false; + while (repeat > 0) : (repeat -= 1) { + for (self.cursels.items) |*cursel_| if (cursel_.*) |*cursel| { + if (cursel.selection) |*sel| { + sel.normalize(); + move_cursor_begin(root, &sel.begin, self.metrics) catch {}; + move_cursor_end(root, &sel.end, self.metrics) catch {}; + blk: { + cursel.cursor.move_down(root, self.metrics) catch |e| switch (e) { + error.Stop => { + cursel.cursor.move_end(root, self.metrics); + break :blk; + }, + }; + move_cursor_begin(root, &cursel.cursor, self.metrics) catch {}; + } + sel.end = cursel.cursor; + } else { + self.select_line_at_cursor(root, cursel, .include_eol) catch {}; + } + }; + self.collapse_cursors(); + } + } + pub const select_line_meta: Meta = .{ .description = "Select current line", .arguments = &.{.integer} }; + + pub fn delete_line(self: *Self, ctx: Context) Result { 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); - }; + var repeat: usize = 1; + _ = ctx.args.match(.{tp.extract(&repeat)}) catch false; + while (repeat > 0) : (repeat -= 1) { + 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(); } - pub const delete_line_meta: Meta = .{ .description = "Delete current line" }; + pub const delete_line_meta: Meta = .{ .description = "Delete current line", .arguments = &.{.integer} }; pub fn cut_to_end_vim(self: *Self, _: Context) Result { const b = try self.buf_for_update();