Skip to content

Fix shift selection in vi (insert) & emacs mode #927

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

collinmurch
Copy link

@collinmurch collinmurch commented Jun 30, 2025

This PR fixes shift selection in vi (insert) & emacs mode. The gist is that we were incorrectly selecitng an additional character when selecting leftwards (holding shift and pressing left arrow). One extra character to the right of the start location was getting highlighted and would be affected by any delete or other operations.

Tested on macOS with both vi & emacs mode. No regression of vi (normal) shift selection functionality.

Fix for this issue: #922 which I think is a duplicate of #893.

@blindFS
Copy link
Contributor

blindFS commented Jun 30, 2025

Thanks, that seems similar but clearer than the solution by Claude #911 .

Noticed one minor issue, steps to reproduce:

  1. selection done in vi normal mode
  2. press c, the last selected character is not deleted.

@collinmurch
Copy link
Author

Yeah, you're totally right; I missed this test case. Should be fixed now, all the modes seem to work for me.

@blindFS
Copy link
Contributor

blindFS commented Jun 30, 2025

Yeah, you're totally right; I missed this test case. Should be fixed now, all the modes seem to work for me.

Your last commit didn't change anything in my setup. Say I have abcdefg in cli with cde selected in vi normal mode.
After pressing c, the result is ab|efg where | represents the cursor.

@blindFS
Copy link
Contributor

blindFS commented Jun 30, 2025

There's another complication: inconsistent behavior of selection in vi normal mode triggered by v or shift + arrow key.
A common issue for #911

@collinmurch
Copy link
Author

collinmurch commented Jun 30, 2025

Okay I pushed up a commit that actually does fix it. My prior one did fix shift selection going leftwards but seems to have just shifted the issue to being present moving to the right for vi normal mode + cut operations. This new commit fixes it for both, but adds some complexity that I don't love.

The core issue is that when we perform the cut operation, we immediately go into insert mode which then messes up the calculation for text to delete. Since we're in insert mode, it selects one character short even though the selection was made with vi normal mode.

Let me know what you think of this. Also, I'm not sure exactly what you're referring to with:

There's another complication: inconsistent behavior of selection in vi normal mode triggered by v or shift + arrow key.

From my experience, I can't even get the two to behave the same on a fresh build of the main branch. It seems that shift selection for vi normal mode has some other bug that makes it operate inconsistently with the cut and other operations.

@blindFS
Copy link
Contributor

blindFS commented Jun 30, 2025

There's another complication: inconsistent behavior of selection in vi normal mode triggered by v or shift + arrow key. A common issue for #911

Yeah I noticed this too but in my testing the same behavior is present in the current build of main. So I think it might be unrelated. Let me know if you disagree.

Yeah, probably rooted elsewhere. OMG...

@blindFS
Copy link
Contributor

blindFS commented Jun 30, 2025

I used to take this issue to test AI agents' capabilities, haha. Never found one that's good enough. Claude 4.0 >> Gemini 2.5 pro on this issue, but still lame.

@collinmurch
Copy link
Author

Yeah since I'm new to this repo claude 4 has helped out with some of this but ultimately I'm having to babysit it pretty aggressively. Keeps wanting to implement hacky one-off fixes.

@collinmurch
Copy link
Author

Any movement on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants