Skip to content
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

First hit of ESC is swallowed by suggestions, have to hit it twice to leave insert mode #677

Closed
lesiki opened this issue Jun 22, 2021 · 13 comments · Fixed by #680
Closed
Assignees

Comments

@lesiki
Copy link

lesiki commented Jun 22, 2021

When the IntelliSense window is visible, hitting escape removes the suggestions but keeps me in insert mode. Initially it 'felt' as though some escape key presses were being dropped, I only figured out that this was what was happening by slowly trying to recreate it.

I'm fairly sure this was just recently introduced in the latest VSCode 1.57.1 release.

The gif below shows me pressing escape (⎋) twice to leave insert mode.

Screenshot 2021-06-22 at 10 05 46

@theol0403
Copy link
Member

Yes, this was introduced by the latest version.

https://github.com/asvetliakov/vscode-neovim/pull/513/files#diff-7ae45ad102eab3b6d7e7896acd08c427a9b25b346470d7bc6507b6481575d519R539

#604

Specifically, it allows parameter hints to swallow, not suggestions. I personally prefer the new way, but I understand if you prefer the old way. A quick fix is to change it in your user keybindings.json.

However, if this bothers too many people, I am happy to revert it, or maybe provide a configuration toggle for it.

Please let me know if this is a popular issue.

@lesiki
Copy link
Author

lesiki commented Jun 22, 2021

Thanks @theol0403 , your suggested quick fix worked.

For anyone else interested in reverting to the old behaviour:

  1. Open keyboard shortcuts (Preferences → Keyboard Shortcuts)
  2. Click the button to the right of the search bar to enter JSON editing mode
  3. Add a key binding with the original when clause:
// Place your key bindings in this file to override the defaults
[
    {
        "command": "vscode-neovim.escape",
        "key": "Escape",
        "when": "editorTextFocus && neovim.init"
    },
]

@theol0403
Copy link
Member

theol0403 commented Jun 22, 2021

👍

Should we keep the issue open? I don't know how much this change bothers other people.

Btw, I think you should keep some of the when conditions, like the peek escape which is useful (when you have a peek open, but then you return to the original editor, escape will close the peek).

Also, iirc doom emacs, one of the best examples of ide functionality + vim, makes escape close popups and notifications before it escapes insert mode.

@theol0403
Copy link
Member

theol0403 commented Jun 22, 2021

Actually, I am wrong with doom emacs, and this is a good issue.

Using escape to close things in normal mode is valid, but maybe not in insert mode.

Maybe, escape should only be sometimes sent to vscode in normal mode (to close things), but always exits insert mode in insert mode.

I'll think about it

@lesiki
Copy link
Author

lesiki commented Jun 22, 2021

A personal opinion that isn't based on how other IDE + Vim implementations solved this: I think escape should always exit insert mode, regardless of any suggestion the IDE might be displaying.

I find it fiddly that depending on the last character I typed in insert mode & the language I'm in, there may or may not be a parameter hint displayed, and the number of ESC hits to get back to normal mode is variable.

It does seem worth keeping as an option for those who disagree. My vote is in favour of the old behaviour being the default.

@asvetliakov
Copy link
Member

I agree, escape must escape the insert mode. Also C-c (which i personally use) is not affected

@theol0403 theol0403 self-assigned this Jun 22, 2021
@theol0403
Copy link
Member

theol0403 commented Jun 22, 2021

The people at #534 seem to have a different opinion, so I think it is best to either have a config option, or a snippet in the readme/wiki. However I think it is safe to intercept in normal mode by default.

However, I agree that escape must escape the insert mode.

theol0403 added a commit to theol0403/vscode-neovim that referenced this issue Jun 24, 2021
theol0403 added a commit to theol0403/vscode-neovim that referenced this issue Jun 25, 2021
@5alidz
Copy link

5alidz commented Jun 26, 2021

Is there a way for the escape key to close the "hints popup" AND exits the insert mode?

@theol0403
Copy link
Member

theol0403 commented Jun 26, 2021

Is there a way for the escape key to close the "hints popup" AND exits the insert mode?

It seems to me that this is actually the case for the most part (with my PR), that the hints popup and suggestions leave when you exit insert mode. Is this not the case for you?

@5alidz
Copy link

5alidz commented Jun 26, 2021

Is there a way for the escape key to close the "hints popup" AND exits the insert mode?

It seems to me that this is actually the case for the most part (with my PR), that the hints popup and suggestions leave when you exit insert mode. Is this not the case for you?

Oh my bad, it's working as expected (exits insert mode & closes popup), I think VS Code chokes sometimes and the popup just follows my cursor in normal mode

@trkoch
Copy link
Collaborator

trkoch commented Nov 19, 2021

Not sure what I prefer. Adding an option would be great.

It does seem worth keeping as an option for those who disagree. My vote is in favour of the old behaviour being the default.

@trkoch
Copy link
Collaborator

trkoch commented Nov 19, 2021

For anybody looking how to cancel prompt without leaving insert mode, try Shift-Esc.

@chuanqisun
Copy link

chuanqisun commented Dec 4, 2021

Second the opinion to not swallow Escape by default, or adding a simple toggle to disable swallowing. The swallowing behavior could be a nice thing for people transitioning from vscode to vim but it's quite unnatural for me as a vim user, because now depending on my situation, I have to pause and think do I have to press Escape once or twice to exit INSERT mode? After a while, I'm building up muscle memory to repetitively hitting Escape in all situations, and that's not a healthy habit to have.

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 a pull request may close this issue.

6 participants