VSCodeVim / VSCodeVim/Vim

Changing to normal mode when clicking is not clearing RecordedState

Open
#5,719 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

kind/bug
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:

  1. Go to insert mode by pressing i or a
  2. Press <C-f> or call the "Find" widget from the command pallete
  3. Write a word to search (this step is probably not needed)
  4. Click somewhere to get the focus out of the "Find" widget (I usually press escape, that's why I never noticed this... 😄 )
  5. It goes into normal mode
  6. Press i or a to 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.