zed icon indicating copy to clipboard operation
zed copied to clipboard

Vim: Selection misses 1 character in Normal Mode

Open hamza72x opened this issue 11 months ago • 1 comments

Check for existing issues

  • [X] Completed

Describe the bug / provide steps to reproduce it

In Vim (Normal Mode) - selecting the block of code misses one character always. In insert mode, it works fine.

Check Following Screencast for explanation.

Environment

Zed: v0.123.6 (Zed) OS: macOS 14.3.1 Memory: 16 GiB Architecture: aarch64

If applicable, add mockups / screenshots to help explain present your vision of the feature

https://github.com/zed-industries/zed/assets/48919542/e23a8eb2-9b3a-4957-a1fc-38714603a7b8

If applicable, attach your ~/Library/Logs/Zed/Zed.log file to this issue.

If you only need the most recent lines, you can run the zed: open log command palette action to see the last 1000.

No response

hamza72x avatar Feb 27 '24 15:02 hamza72x

After doing more testing, this happens only when using the mouse and selecting upward.

I feel as if this is a bias issue, because it seem's like this problem appeared when visual mode was being implemented, and was only fixed for vim motions. It is described in a comment in vim/src/visual.rs:83

I will look further for a fix or a direct cause.

bobby-burns avatar Feb 28 '24 18:02 bobby-burns

@bobby-burns happy to work with you on this if you'd like too: https://calendly.com/conradirwin/pairing; but I think you're right.

The tricky thing may be knowing that the selection was recently created from a mouse event; but we may also be able to reasonable assume that's the only way to jump from normal mode to visual mode without using a vim command...

ConradIrwin avatar Feb 29 '24 02:02 ConradIrwin

@bobby-burns this also happens in plain horizontal selection as well.

hamza72x avatar Feb 29 '24 07:02 hamza72x

@bobby-burns this also happens in plain horizontal selection as well.

I think he means selecting to the left ("upwards"), and not necessarily selecting across rows.

EDIT: this dual behavior occurs only when the initially selected character is at the end of the line; we should probably consider implementing something similar for Zed as well.

I think we also need to consider what the intended behavior should be.

https://github.com/zed-industries/zed/assets/65467530/a082f17b-cd9e-47fe-b3b0-ee0770dc4cfc

This video demonstrates VSCode's behavior with Vim mode, which, despite the . being selected in both circumstances initially, it is included in the first selection and not the second (likely because the mouse is initially shifted slightly to the left in the latter situation).

danielzsh avatar Mar 22 '24 18:03 danielzsh