fix vim repeat (#8513)

Release Notes:

- vim: Fixed `.` when multiple windows are open
([#7446](https://github.com/zed-industries/zed/issues/7446)).
- vim: Fixed switching to normal mode after `J`, `<` or `>` in visual
mode ([#4439](https://github.com/zed-industries/zed/issues/4439))
- vim: Added `ctrl-t` and `ctrl-d` for indent/outdent in insert mode.

- Fixed indent/outdent/join lines appearing to work in read-only buffers
([#8423](https://github.com/zed-industries/zed/issues/8423))
- Fixed indent with an empty selection when the cursor was in column 0
This commit is contained in:
Conrad Irwin
2024-02-27 21:36:12 -07:00
committed by GitHub
parent 9a7a267203
commit 9906b31691
7 changed files with 82 additions and 48 deletions
+10 -1
View File
@@ -4474,6 +4474,9 @@ impl Editor {
}
pub fn indent(&mut self, _: &Indent, cx: &mut ViewContext<Self>) {
if self.read_only(cx) {
return;
}
let mut selections = self.selections.all::<Point>(cx);
let mut prev_edited_row = 0;
let mut row_delta = 0;
@@ -4516,7 +4519,7 @@ impl Editor {
// If a selection ends at the beginning of a line, don't indent
// that last line.
if selection.end.column == 0 {
if selection.end.column == 0 && selection.end.row > selection.start.row {
end_row -= 1;
}
@@ -4567,6 +4570,9 @@ impl Editor {
}
pub fn outdent(&mut self, _: &Outdent, cx: &mut ViewContext<Self>) {
if self.read_only(cx) {
return;
}
let display_map = self.display_map.update(cx, |map, cx| map.snapshot(cx));
let selections = self.selections.all::<Point>(cx);
let mut deletion_ranges = Vec::new();
@@ -4707,6 +4713,9 @@ impl Editor {
}
pub fn join_lines(&mut self, _: &JoinLines, cx: &mut ViewContext<Self>) {
if self.read_only(cx) {
return;
}
let mut row_ranges = Vec::<Range<u32>>::new();
for selection in self.selections.all::<Point>(cx) {
let start = selection.start.row;