vim: Fix and improve horizontal scrolling (#33590)
This Pull Request introduces various changes to the editor's horizontal scrolling, mostly focused on vim mode's horizontal scroll motions (`z l`, `z h`, `z shift-l`, `z shift-h`). In order to make it easier to review, the logical changes have been split into different sections. ## Cursor Position Update Changes introduced on https://github.com/zed-industries/zed/pull/32558 added both `z l` and `z h` to vim mode but it only scrolled the editor's content, without changing the cursor position. This doesn't reflect the actual behavior of those motions in vim, so these two commits tackled that, ensuring that the cursor position is updated, only when the cursor is on the left or right edges of the editor: -ea3b866a76
-805f41a913
## Horizontal Autoscroll Fix After introducing the cursor position update to both `z l` and `z h` it was noted that there was a bug with using `z l`, followed by `0` and then `z l` again, as on the second use `z l` the cursor would not be updated. This would only happen on the first line in the editor, and it was concluded that it was because the `editor:📜:autoscroll::Editor.autoscroll_horizontally` method was directly updating the scroll manager's anchor offset, instead of using the `editor:📜:Editor.set_scroll_position_internal` method, like is being done by the vertical autoscroll (`editor:📜:autoscroll::Editor.autoscroll_vertically`). This wouldn't update the scroll manager's anchor, which would still think it was at `(0, 1)` so the cursor position would not be updated. The changes in [this commit](3957f02e18
) updated the horizontal autoscrolling method to also leverage `set_scroll_position_internal`. ## Visible Column Count & Page Width Scroll Amount The changes ind83652c3ae
add a `visible_column_count` field to `editor:📜:ScrollManager` struct, which allowed the introduction of the `ScrollAmount::PageWidth` enum. With these changes, two new actions are introduced, `vim::normal:📜:HalfPageRight` and `vim::normal:📜:HalfPageLeft` (in7f344304d5
), which move the editor half page to the right and half page to the left, as well as the cursor position, which have also been mapped to `z shift-l` and `z shift-h`, respectively. Closes #17219 Release Notes: - Improved `z l` and `z h` to actually move the cursor position, similar to vim's behavior - Added `z shift-l` and `z shift-h` to scroll half of the page width's to the right or to the left, respectively --------- Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
This commit is contained in:
parent
6b7c30d7ad
commit
139af02737
7 changed files with 209 additions and 27 deletions
|
@ -189,6 +189,8 @@
|
|||
"z shift-r": "editor::UnfoldAll",
|
||||
"z l": "vim::ColumnRight",
|
||||
"z h": "vim::ColumnLeft",
|
||||
"z shift-l": "vim::HalfPageRight",
|
||||
"z shift-h": "vim::HalfPageLeft",
|
||||
"shift-z shift-q": ["pane::CloseActiveItem", { "save_intent": "skip" }],
|
||||
"shift-z shift-z": ["pane::CloseActiveItem", { "save_intent": "save_all" }],
|
||||
// Count support
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue