# Make editor::LineUp & editor::LineDown honor vertical_scroll_margin like vim::LineUp & vim::LineDown \(\#52057\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/029bf2f284b4e59f20175d78443e630468f3a3e5)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 029bf2f284b4e59f20175d78443e630468f3a3e5

Requested commit: 029bf2f284b4e59f20175d78443e630468f3a3e5

Commit: 029bf2f284b4e59f20175d78443e630468f3a3e5

Tree: 1dddc8fd43f7b2f2c570c5614987357bfc8366d5

Author: TwoClocks

Committer: GitHub

## Message

```
Make editor::LineUp & editor::LineDown honor vertical_scroll_margin like vim::LineUp & vim::LineDown (#52057)

## Context

This is an implementation of this feature:
https://github.com/zed-industries/zed/discussions/49821

Although, I'd argue it's a bug fix, not a feature.

Either way : This copies the window scroll logic from the `vim` mode
versions with out all the extra logic for visual mode.

Could refactor the common logic out of the vim code and make it common.
But that seems like a bigger PR. Happy to take a stab at it if that's
what you prefer.
Could also add new commands for the new behavior if you prefer. I didn't
do that, because it seems like more clutter in the commands, and my
belief that the existing behavior is a bug. But happy to do that if you
prefer.

## How to Review

creates new function `scroll_screen_with_cursor_margin` in `scroll.rs`
wires up editor::LineUp/LineDown to new function in `elements.rs`
adds a test in  `editor_tests.rs`

## Self-Review Checklist

<!-- Check before requesting review: -->
- [X] I've reviewed my own diff for quality, security, and reliability
- [X] Unsafe blocks (if any) have justifying comments
- [X] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [X] Tests cover the new/changed behavior
- [X] Performance impact has been considered and is acceptable

Release Notes:

- editor::LineUp/LineDown commands now honor vertical_scroll_margin
(same as vim::LineUp/LineDown)

---------

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
```

## Parents

- [7f5cf583dc72035efe68cb3ef086857cda0c7a47](https://git.cafe/gitcafe/zed/commit/7f5cf583dc72035efe68cb3ef086857cda0c7a47?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/029bf2f284b4e59f20175d78443e630468f3a3e5?format=markdown)
