Vim icon indicating copy to clipboard operation
Vim copied to clipboard

added revert to normal mode in case of bad sequence of selectionchang…

Open teslae1 opened this issue 11 months ago • 4 comments

What this PR does / why we need it: Fixes mouseclick at eol when in normal mode sometimes triggers visual mode.

I was able to reproduce the problem - the core issue is that vscode sometimes issues a specific sequence of selection change events on a single mouse click. When the error occurs the sequence of events for the single mouse click is:

  1. Selection change event that selects the last character of the line
  • This causes the change to visual mode
  1. Selection change event that selects no characters and is at end of line
  • This moves the cursor to the end of line having no characters selected

These two events leave the editor in the state which was also shown in the issue: visual mode and no characters selected.

Which issue(s) this PR fixes #9887

teslae1 avatar Jan 03 '26 18:01 teslae1

  1. Selection change event that selects the last character of the line
  • This causes the change to visual mode

Is there a way to detect this, and prevent it from changing the mode, rather than reverting it after the fact?

J-Fields avatar Jan 03 '26 21:01 J-Fields

  1. Selection change event that selects the last character of the line
  • This causes the change to visual mode

Is there a way to detect this, and prevent it from changing the mode, rather than reverting it after the fact?

I tried researching this (I agree it would be best to never end up in the bad state), but the fact that the first event in isolation is a completely viable event that is also dispatched when a user left clicks and drags to select the last char of a line lead me to the conclusion that we can only detect this after the fact.

teslae1 avatar Jan 04 '26 11:01 teslae1

@J-Fields Hey Jason, just wanted to know if there is anything I myself can do to move my pr's along (including the one belonging to this conversation) https://github.com/VSCodeVim/Vim/pull/9874 https://github.com/VSCodeVim/Vim/pull/9872 https://github.com/VSCodeVim/Vim/pull/9894 https://github.com/VSCodeVim/Vim/pull/9895 https://github.com/VSCodeVim/Vim/pull/9896

teslae1 avatar Jan 16 '26 09:01 teslae1

Hey again @J-Fields , let me know if I can help in any way. Just wanted to add to the list of pending pr's I have: https://github.com/VSCodeVim/Vim/pull/9911 https://github.com/VSCodeVim/Vim/pull/9910 https://github.com/VSCodeVim/Vim/pull/9901

teslae1 avatar Jan 29 '26 11:01 teslae1