Make Copy and Trim ignore empty lines, and fix vim line selections (#29019)
Close #28519 Release Notes: Update `editor: copy and trim` command: 1. Ignore empty lines in the middle: ``` Line 1 Line 2 ``` Will copy text to clipboard: ``` Line 1 Line 2 ``` Before this commit trim not performed 1. Fix select use vim line selections, trim not works
This commit is contained in:
parent
5f7189e5af
commit
72218f4a61
2 changed files with 40 additions and 2 deletions
|
@ -10155,11 +10155,19 @@ impl Editor {
|
|||
..Point::new(row.0, buffer.line_len(row)),
|
||||
);
|
||||
for row in start.row + 1..=end.row {
|
||||
let mut line_len = buffer.line_len(MultiBufferRow(row));
|
||||
if row == end.row {
|
||||
line_len = end.column;
|
||||
}
|
||||
if line_len == 0 {
|
||||
trimmed_selections
|
||||
.push(Point::new(row, 0)..Point::new(row, line_len));
|
||||
continue;
|
||||
}
|
||||
let row_indent_size = buffer.indent_size_for_line(MultiBufferRow(row));
|
||||
if row_indent_size.len >= first_indent.len {
|
||||
trimmed_selections.push(
|
||||
Point::new(row, first_indent.len)
|
||||
..Point::new(row, buffer.line_len(MultiBufferRow(row))),
|
||||
Point::new(row, first_indent.len)..Point::new(row, line_len),
|
||||
);
|
||||
} else {
|
||||
trimmed_selections.clear();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue