# editor: Fix crash when pasting after copy and trim in visual line mode \(\#46640\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 0ecefe031ee8a5bd43d6d9a3e94e110cd1febf64

Requested commit: 0ecefe031ee8a5bd43d6d9a3e94e110cd1febf64

Commit: 0ecefe031ee8a5bd43d6d9a3e94e110cd1febf64

Tree: dd5e9c4e43e75ec5e46738f726c0e766e7cefd5e

Author: Dino

Committer: GitHub

## Message

```
editor: Fix crash when pasting after copy and trim in visual line mode (#46640)

When using the `editor::actions::CopyAndTrim` action with a multi-line
selection in vim's Visual Line mode, pasting would crash Zed.

The bug occurred because trimming splits a selection into per-line
ranges, creating multiple `editor::ClipboardSelection` entries. However,
when `is_entire_line` was true (Visual Line mode), no newline separators
were added between these entries in the clipboard text. The paste code
then assumed separators existed and read past the end of the text.

The fix ensures newline separators are always added between trimmed line
ranges, regardless of whether the original selection was in line mode.

Closes #46616 

Release Notes:

- Fixed a crash when pasting after using `editor: copy and trim` in
vim's Visual Line mode
```

## Parents

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

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