# editor: Fix block cursor offset when selecting text \(\#42837\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 5fe7fd97bd00e8273e1e03bdc37952c82fc0927c

Requested commit: 5fe7fd97bd00e8273e1e03bdc37952c82fc0927c

Commit: 5fe7fd97bd00e8273e1e03bdc37952c82fc0927c

Tree: 75b75714b2d29086bf55aa48dd98110561af94d1

Author: Lennart

Committer: GitHub

## Message

```
editor: Fix block cursor offset when selecting text (#42837)

Vim visual mode and Helix selection mode both require the cursor to be
on the last character of the selection. Until now, this was implemented
by offsetting the cursor one character to the left whenever a block
cursor is used. (Since the visual modes use a block cursor.)

However, this oversees the problem that **some users might want to use
the block cursor without being in visual mode**. Meaning that the cursor
is offset by one character to the left even though Vim/Helix mode isn't
even activated.

Since the Vim mode implementation is separate from the `editor` crate
the solution is not as straightforward as just checking the current vim
mode. Therefore this PR introduces a new `Editor` struct field called
`cursor_offset_on_selection`. This field replaces the previous check 
condition and is set to `true` whenever the Vim mode is changed to a 
visual mode, and `false` otherwise.

Closes #36677 and #20121

Release Notes:

- Fixes block and hollow cursor being offset when selecting text

---------

Co-authored-by: dino <dinojoaocosta@gmail.com>
```

## Parents

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

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