Skip to content

Changing to normal mode when clicking is not clearing RecordedState #5719

@berknam

Description

@berknam

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 #3372 (comment).

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions