# Fix an interaction between vim's linewise yank and editor's paste \(\#33555\) · gitcafe/zed

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

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

Visibility: public

Requested revision: b0086b472f69804a5201b749d76bb7a746bd1027

Requested commit: b0086b472f69804a5201b749d76bb7a746bd1027

Commit: b0086b472f69804a5201b749d76bb7a746bd1027

Tree: 1d0214a81bdb780724340cfba3e55219f094f0a9

Author: Alejandro Fernández Gómez

Committer: GitHub

## Message

```
Fix an interaction between vim's linewise yank and editor's paste (#33555)

Closes #32397

This PR fixes an issue when pasting text with the `editor::Paste`
command that was copied with `vim::Yank`'s linewise selection.

The change stops setting the `is_entire_line` setting when copying from
with vim linewise selections (<kbd>⇧v</kbd>) and motions (i.e.
<kbd>y2j</kbd>).

This flag is used when cutting/copying text without being selected (so,
place a cursor on line without selecting anything, and press
<kbd>⌘X</kbd>). When cutting/copying text in this manner, [the editor
pastes the text above the
cursor](https://github.com/afgomez/zed/blob/36941253ee086af3dc7d2b2729a68bebe387d650/crates/editor/src/editor.rs#L11936-L11947).
However, this behaviour is not needed when cutting/copying with vim
motions.

Pasting with vim operations is not affected by this change. [They are
handled
elsewhere](https://github.com/afgomez/zed/blob/36941253ee086af3dc7d2b2729a68bebe387d650/crates/vim/src/normal/paste.rs)
and they don't consider the `is_entire_line` flag at all.

Note for maintainers: I'm not familiar with this codebase 🙃. This change
fixes the issue. I don't see anything breaking... but let me know if
it's not the case and a more thorough change is needed.

**Before:**

The text is copied above the first line, before the cursor.


https://github.com/user-attachments/assets/0c2f111a-5da0-4775-a7a0-2e4fb6f78bfc


**After:**
The text is copied at the cursor location:


https://github.com/user-attachments/assets/60a17985-fe8b-4149-a77b-d72bf531bf85


Release Notes:

- Fixed an issue when pasting text that was yanked with vim's linewise
selections.
```

## Parents

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

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