refactor: use select_line_at_cursor to simplify cut command
This commit is contained in:
parent
c27795bc95
commit
772e2e7d29
1 changed files with 2 additions and 13 deletions
|
|
@ -2698,19 +2698,8 @@ pub const Editor = struct {
|
|||
const primary = self.get_primary();
|
||||
const b = self.buf_for_update() catch return;
|
||||
var root = b.root;
|
||||
if (self.cursels.items.len == 1)
|
||||
if (primary.selection) |_| {} else {
|
||||
const sel = primary.enable_selection(root, self.metrics) catch return;
|
||||
try move_cursor_begin(root, &sel.begin, self.metrics);
|
||||
move_cursor_end(root, &sel.end, self.metrics) catch |e| switch (e) {
|
||||
error.Stop => {},
|
||||
else => return e,
|
||||
};
|
||||
move_cursor_right(root, &sel.end, self.metrics) catch |e| switch (e) {
|
||||
error.Stop => {},
|
||||
else => return e,
|
||||
};
|
||||
};
|
||||
if (self.cursels.items.len == 1 and primary.selection == null)
|
||||
try self.select_line_at_cursor(root, primary, .include_eol);
|
||||
var count: usize = 0;
|
||||
for (self.cursels.items) |*cursel_| if (cursel_.*) |*cursel| {
|
||||
count += 1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue