# vim: Fix temporary mode exit on end of line \(\#42742\) · gitcafe/zed

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

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

Visibility: public

Requested revision: cdcc068906636f74a26e4ded50bb7140633188c0

Requested commit: cdcc068906636f74a26e4ded50bb7140633188c0

Commit: cdcc068906636f74a26e4ded50bb7140633188c0

Tree: f3787abd41132560d27c121a21ca9fc6031d2c62

Author: Dino

Committer: GitHub

## Message

```
vim: Fix temporary mode exit on end of line (#42742)

When using the end of line motion ($) while in temporary mode, the
cursor would be placed in insert mode just before the last character
instead of after, just like in NeoVim.

This happens because `EndOfLine` kind of assumes that we're in `Normal`
mode and simply places the cursor in the last character instead of the
newline character.

This commit moves the cursor one position to the right when exiting
temporary mode and the motion used was `Motion::EndOfLine`

- Update `vim::normal::Vim.exit_temporary_normal` to now accept a
`Option<&Motion>` argument, in case callers want this new logic to
potentially be applied

Closes #42278 

Release Notes:

- Fixed temporary mode exit when using `$` to move to the end of the
line
```

## Parents

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

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