VSCodeVim / Vim

:star: Vim for Visual Studio Code
http://aka.ms/vscodevim
MIT License
13.96k stars 1.32k forks source link

Visual mode cannot be navigated with up/down arrow keys #5029

Closed quorth0n closed 4 years ago

quorth0n commented 4 years ago

Describe the bug Visual mode cannot be navigated with up/down arrow keys. I guess this is a good time to get used to h/j/k/l :sweat_smile:

To Reproduce Steps to reproduce the behavior:

  1. Press v to enter visual mode
  2. Move left/right with arrow keys, works.
  3. Move up/down with arrow keys, exits visual mode into normal mode
sbrocket commented 4 years ago

+1, I'm also experiencing this with 1.15.0 of the extension and VSCode 1.47.1, though my local OS is macOS 10.15.5.

The behavior doesn't start immediately when the VSCode window is loaded, and initially arrow keys will work in visual mode. At some point though it will stop working and arrow keys will pop you out of visual mode again. Reloading the window (as in the "Developer: Reload Window" action) temporarily makes it work again, presumably because it reloads extensions and resets whatever state is bad, but it just occurs again after some time.

I was able to workaround the issue by downgrading the extension to 1.14.5, so it seems like a regression in the new release.

skipper2cic commented 4 years ago

Same to me. After recent update of VSCode 1.47.1, visual block doesn't work with up/down arrows. My local OS is Windows 10.

J-Fields commented 4 years ago

I'm unable to reproduce. Could someone post their settings and keybindings, please?

reneklacan commented 4 years ago

Experiencing the same issue but not immediately after starting VS, it only starts to happen after a random amount of minutes. I have no idea what triggers it.

As I'm not experiencing it consistently, my keybindings would probably not help :-/.

sbrocket commented 4 years ago

I don't have any non-default settings for VSCodeVim.

https://gist.github.com/sbrocket/4095bd960e25b1946aa73b735009445a

ZoltanDalmadi commented 4 years ago

Can confirm. Reload window (Ctrl + R) command fixes it, but after a certain (random) amount of time it breaks again. Very annoying. :/

berknam commented 4 years ago

I'm also unable to reproduce this.

Has anyone noticed any sort of pattern in the time it takes to start failing, or what were you doing when it started failing (as in, were you using something like macros or remapped keys, were you using something from other extension, does it happen in different file types?)

Also can someone with this affecting them set the "vim.debug.loggingLevelForConsole": "debug" and then check on the developer tools console ('Help' -> 'Toggle Developer Tools' -> 'Console' tab) if the keys <up> and <down> are showing up with something like this ModeHandler: debug: handling key=<up>.

markperri commented 4 years ago

It's been happening to me the last couple of days, but now that I set "vim.debug.loggingLevelForConsole": "debug" I can't reproduce it.

quorth0n commented 4 years ago

The bug is still happening to me. @berknam I'm not seeing log statements in the console for any keypress, other than an initial [Extension Host] Configuration: debug: 0 errors found with vim configuration

berknam commented 4 years ago

The bug is still happening to me. @berknam I'm not seeing log statements in the console for any keypress, other than an initial [Extension Host] Configuration: debug: 0 errors found with vim configuration

Make sure that "vim.debug.silent": false is not set to true. You should see the logs whenever you press a key that Vim extension catches.

markperri commented 4 years ago

Got it to happen again. After shift-V and then up arrow I don't get any up arrow debug messages, just:

[Extension Host] ModeHandler: debug: handleKeyEvent('') took 5ms console.ts:137 [Extension Host] ModeHandler: debug: handling key=V. console.ts:137 [Extension Host] Remapper: debug: trying to find matching remap. keys=V. mode=Normal. keybindings=normalModeKeyBindingsMap. console.ts:137 [Extension Host] Remapper: debug: trying to find matching remap. keys=V. mode=Normal. keybindings=normalModeKeyBindingsNonRecursiveMap. console.ts:137 [Extension Host] ModeHandler: debug: handleKeyEvent('V') took 12ms

Vk works though: [Extension Host] ModeHandler: debug: handleKeyEvent('') took 5ms console.ts:137 [Extension Host] ModeHandler: debug: handling key=V. console.ts:137 [Extension Host] Remapper: debug: trying to find matching remap. keys=V. mode=Normal. keybindings=normalModeKeyBindingsMap. console.ts:137 [Extension Host] Remapper: debug: trying to find matching remap. keys=V. mode=Normal. keybindings=normalModeKeyBindingsNonRecursiveMap. console.ts:137 [Extension Host] ModeHandler: debug: handleKeyEvent('V') took 17ms console.ts:137 [Extension Host] ModeHandler: debug: handling key=k. console.ts:137 [Extension Host] Remapper: debug: trying to find matching remap. keys=k. mode=VisualLine. keybindings=visualModeKeyBindingsMap. console.ts:137 [Extension Host] Remapper: debug: trying to find matching remap. keys=k. mode=VisualLine. keybindings=visualModeKeyBindingsNonRecursiveMap. console.ts:137 [Extension Host] ModeHandler: debug: handleKeyEvent('k') took 2ms  ​

berknam commented 4 years ago

Maybe there is another extension capturing the up/down keys because they aren't getting into vim. Check the 'Keyboard Shortcuts' if there are any other extensions using the "up" and "down" keys. You should see the vim ones there (extension.vim_up and extension.vim_down) and there should be some others from vscode. If there is any from other extension, try disabling that extension to see if it fixes the issue.

sbrocket commented 4 years ago

An extension conflict seems unlikely given that this is a regression, which is evidenced by 1.14.5 not exhibiting the same behavior with the same version of VSCode and same extensions.

I haven’t had a chance to try the debugging steps above yet this week, but will try them tonight and see what I find.

berknam commented 4 years ago

Vk works though: [Extension Host] ModeHandler: debug: handleKeyEvent('') took 5ms

@markperri Was this a typo or was the handleKeyEvent('') really empty? What did you press before the 'V' key?

berknam commented 4 years ago

An extension conflict seems unlikely given that this is a regression, which is evidenced by 1.14.5 not exhibiting the same behavior with the same version of VSCode and same extensions.

I haven’t had a chance to try the debugging steps above yet this week, but will try them tonight and see what I find.

Yeah you're probably right. It's just that since that seems to be a bit random and it doesn't happen right away or every time there is the possibility that when you downgraded the issue might have been there still but just didn't happen at that moment.

I've seen a few issues with keys like this that usually are caused by other extensions 'stealing' the keys.

Also has any of you been toggling the Vim extension with the command Vim: Toggle Vim Mode? I've sometimes had an issue where after toggling the Vim mode it would get into some weird state where some keys wouldn't work while others did. I think it was because the vim.active context didn't update properly so the keys that rely on that didn't work. (when that happened, just toggling the mode again would resolve the issue)

markperri commented 4 years ago

Vk works though: [Extension Host] ModeHandler: debug: handleKeyEvent('') took 5ms

@markperri Was this a typo or was the handleKeyEvent('') really empty? What did you press before the 'V' key?

Weird, that should be Esc. I wonder if markup is removing it somehow.

console.ts:137 [Extension Host] ModeHandler: debug: handling key=<Esc>. console.ts:137 [Extension Host] Remapper: debug: trying to find matching remap. keys=<Esc>. mode=Normal. keybindings=normalModeKeyBindingsMap. console.ts:137 [Extension Host] Remapper: debug: trying to find matching remap. keys=<Esc>. mode=Normal. keybindings=normalModeKeyBindingsNonRecursiveMap. console.ts:137 [Extension Host] ModeHandler: debug: handleKeyEvent('<Esc>') took 7ms console.ts:137 [Extension Host] ModeHandler: debug: handling key=V. console.ts:137 [Extension Host] Remapper: debug: trying to find matching remap. keys=V. mode=Normal. keybindings=normalModeKeyBindingsMap. console.ts:137 [Extension Host] Remapper: debug: trying to find matching remap. keys=V. mode=Normal. keybindings=normalModeKeyBindingsNonRecursiveMap. console.ts:137 [Extension Host] ModeHandler: debug: handleKeyEvent('V') took 17ms

yseymour commented 4 years ago

Just chiming in to add that I also have the same issue with 1.15 on a couple of different machines and it is not confined to visual mode, arrow keys stop working after a while in normal mode as well.

yedhink commented 4 years ago

@J-Fields I have made a gif of this error while i was working on a project. Hope this helps. https://gfycat.com/defenselessfluffyirukandjijellyfish

Context

I get the errors at random times. Nothing specific that i can find which triggers the error.

Extensions which are currently installed.

alefragnani.project-manager
asvetliakov.vscode-neovim **(disabled while recording)**
christian-kohler.path-intellisense
dbankier.vscode-instant-markdown
dsznajder.es7-react-js-snippets
Equinusocio.vsc-material-theme
equinusocio.vsc-material-theme-icons
Gruntfuggly.todo-tree
hediet.vscode-drawio
James-Yu.latex-workshop
jpoissonnier.vscode-styled-components
ms-python.python
oderwat.indent-rainbow
PKief.material-icon-theme
ritwickdey.LiveServer
Shan.code-settings-sync
streetsidesoftware.code-spell-checker
teabyii.ayu **(disabled while recording)**
vscodevim.vim

Notes on the recording

Video showing what is happening

https://giant.gfycat.com/DefenselessFluffyIrukandjijellyfish.webm

berknam commented 4 years ago

Can you try doing the following when that happens:

markperri commented 4 years ago

I think it's due to 9441a5e350d8261f27c031c9a2b360b2effe972d #4994

When I trigger parameter hints on an object in python that has multiple pages of hints (param **kwargs, param map, param iterable), this starts happening. It looks like parameterHintsMultipleSignatures stays true forever after doing this.

editorHasSelection: false editorTextFocus: true parameterHintsMultipleSignatures: true

yedhink commented 4 years ago

@berknam It occurred randomly once again. Following are the outputs for the inspect context keys object:

editorHasSelection: false
editorTextFocus: true
parameterHintsMultipleSignatures: true
suggestWidgetVisible: false
vim.active: true
vim.mode: "Normal"
vim.use<down>: true
vim.use<up>: true

Also got thee following error when trying Inspect Context Keys. Not sure if helpful.

Activating extension 'vscode.extension-editing' failed: Cannot find module '/snap/code-insiders/482/usr/share/code-insiders/resources/app/extensions/extension-editing/dist/extensionEditingMain'
Require stack:
- /snap/code-insiders/482/usr/share/code-insiders/resources/app/out/vs/loader.js
- /snap/code-insiders/482/usr/share/code-insiders/resources/app/out/bootstrap-amd.js
- /snap/code-insiders/482/usr/share/code-insiders/resources/app/out/bootstrap-fork.js.
berknam commented 4 years ago

Can you try adding this to your 'keybindings.json' file and see if it fixes it:

    {
        "key": "down",
        "command": "extension.vim_down",
        "when": "editorTextFocus && vim.active && !inDebugRepl && !parameterHintsVisible && !suggestWidgetVisible"
    },
    {
        "key": "up",
        "command": "extension.vim_up",
        "when": "editorTextFocus && vim.active && !inDebugRepl && !parameterHintsVisible && !suggestWidgetVisible"
    },

You can get to this file with command palette "Preferences: Open Keyboard Shortcuts (JSON)".

berknam commented 4 years ago

Thank you everyone for the help. I think PR #5029 should fix this.

danstewart commented 9 months ago

Sorry for the comment on an old issue but this was the first result on Google.

If someone else runs into a similar issue check if you have Windows Default Keybindings, if so try removing it.