Changing to normal mode when clicking is not clearing RecordedState
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 15.2k
- Forks
- 1.5k
- Avg merge
- 3d 18h
- Merged PRs (30d)
- 6
Description
Describe the bug
Currently when vscode creates a selection (like when using the "Find" widget) we go to visual mode. If the user then presses escape on the widget or closes the widget we are still in visual mode and if we press escape or use an operator everything works fine. However if the user clicks somewhere to get out of the widget instead of pressing escape or closing the widget, then the handleSelectionChange function changes the mode to normal, however since there was no action executed the RecordedState doesn't change and if we were on insert mode when calling the "Find" widget, the RecordedState will still have the action that was used to go to insert mode on the actionsRun.
This was mentioned by @ElvenSpellmaker here https://github.com/VSCodeVim/Vim/issues/3372#issuecomment-731133587.
To Reproduce
Steps to reproduce the behavior:
- Go to insert mode by pressing
iora - Press
<C-f>or call the "Find" widget from the command pallete - Write a word to search (this step is probably not needed)
- Click somewhere to get the focus out of the "Find" widget (I usually press escape, that's why I never noticed this... 😄 )
- It goes into normal mode
- Press
iorato go to insert mode again and it fails...
Expected behavior
The recorded state should be cleared when we change to normal mode after a mouse click.
Additional Context
@J-Fields We could simply clear the vimState.recordedState when changing mode after the click or we could add that logic to the VimState.setMode function. Which one do you think it's better?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at handleSelectionChange and VimState.setMode, then inspect how RecordedState and actionsRun are updated when the mode changes after a mouse click. Reproduce the Find-widget flow from insert mode; done when clicking out enters normal mode, clears the recorded state, and allows i or a to enter insert mode again.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100