vim: Add Separator and RemoveIndent in Join Lines, fix gJ use space join (#22496)

Closes #22492

Release Notes:

- Added Join Lines Separator And RemoveIndent

---------

Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
This commit is contained in:
0x2CA 2025-01-08 01:04:49 +08:00 committed by GitHub
parent 677868ba1a
commit 4deab8a0b9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 98 additions and 26 deletions

View file

@ -5851,7 +5851,7 @@ impl Editor {
});
}
pub fn join_lines(&mut self, _: &JoinLines, cx: &mut ViewContext<Self>) {
pub fn join_lines_impl(&mut self, insert_whitespace: bool, cx: &mut ViewContext<Self>) {
if self.read_only(cx) {
return;
}
@ -5893,11 +5893,12 @@ impl Editor {
let indent = snapshot.indent_size_for_line(next_line_row);
let start_of_next_line = Point::new(next_line_row.0, indent.len);
let replace = if snapshot.line_len(next_line_row) > indent.len {
" "
} else {
""
};
let replace =
if snapshot.line_len(next_line_row) > indent.len && insert_whitespace {
" "
} else {
""
};
this.buffer.update(cx, |buffer, cx| {
buffer.edit([(end_of_line..start_of_next_line, replace)], None, cx)
@ -5911,6 +5912,10 @@ impl Editor {
});
}
pub fn join_lines(&mut self, _: &JoinLines, cx: &mut ViewContext<Self>) {
self.join_lines_impl(true, cx);
}
pub fn sort_lines_case_sensitive(
&mut self,
_: &SortLinesCaseSensitive,