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
|
@ -5121,6 +5121,36 @@ if is_entire_line {
|
|||
),
|
||||
"When selecting past the indent, nothing is trimmed"
|
||||
);
|
||||
|
||||
cx.set_state(
|
||||
r#" «for selection in selections.iter() {
|
||||
let mut start = selection.start;
|
||||
|
||||
let mut end = selection.end;
|
||||
let is_entire_line = selection.is_empty();
|
||||
if is_entire_line {
|
||||
start = Point::new(start.row, 0);
|
||||
ˇ» end = cmp::min(max_point, Point::new(end.row + 1, 0));
|
||||
}
|
||||
"#,
|
||||
);
|
||||
cx.update_editor(|e, window, cx| e.copy_and_trim(&CopyAndTrim, window, cx));
|
||||
assert_eq!(
|
||||
cx.read_from_clipboard()
|
||||
.and_then(|item| item.text().as_deref().map(str::to_string)),
|
||||
Some(
|
||||
"for selection in selections.iter() {
|
||||
let mut start = selection.start;
|
||||
|
||||
let mut end = selection.end;
|
||||
let is_entire_line = selection.is_empty();
|
||||
if is_entire_line {
|
||||
start = Point::new(start.row, 0);
|
||||
"
|
||||
.to_string()
|
||||
),
|
||||
"Copying with stripping should ignore empty lines"
|
||||
);
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue