Vim: Visual mode cannot be navigated with up/down arrow keys

Created on 15 Jul 2020  Â·  23Comments  Â·  Source: VSCodeVim/Vim

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
  • Extension (VsCodeVim) version: 1.15.0
  • VSCode version: 1.47.1
  • OS: Ubuntu
kinbug

Most helpful comment

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

All 23 comments

+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.

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.

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

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 :-/.

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

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

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

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>.

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.

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

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.

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

​

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.

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.

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?

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)

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

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.

@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.

  • I am not sure if extensions or settings are causing it.
  • I dont know how to debug the source of this error.
  • working on a nodejs project - uses js/ts intellisense
  • I will keep the vscode instance(workspace where error occured) open, so that if you need more info i could post here
  • New settings that i added for debugging:-
 "vim.debug.silent": false,
 "vim.debug.loggingLevelForConsole": "debug"
  • Os info
Version: 1.48.0-insider
Commit: cb31fc6ce2b4da3520392b622aa3ebc5b313533b
Date: 2020-07-15T05:32:05.866Z
Electron: 8.3.3
Chrome: 80.0.3987.165
Node.js: 12.13.0
V8: 8.0.426.27-electron.0
OS: Linux x64 4.15.0-111-generic snap Ubuntu 18.04.4 LTS(bionic)

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

  • I was working on a project and suddenly the error occurred.
  • left,right,h,j,k,l keys works fine with visual selection(v, V, <C-v>) and it shows up in dev console
  • up and down arrow not detected.
  • Found some weird keymaps which i havent pressed in the console. I couldn't find a single , in my dev console. But i found this:-
console.ts:137 [Extension Host] ModeHandler: debug: handling key=<C-pageup>. (at t.ConsoleForElectron.log (/home/ikigai/.vscode-insiders/extensions/vscodevim.vim-1.15.0/out/extension.js:9:355338))
console.ts:137 [Extension Host] Remapper: debug: trying to find matching remap. keys=<C-pageup>. mode=Normal. keybindings=normalModeKeyBindingsMap. (at t.ConsoleForElectron.log (/home/ikigai/.vscode-insiders/extensions/vscodevim.vim-1.15.0/out/extension.js:9:355338))
console.ts:137 [Extension Host] Remapper: debug: trying to find matching remap. keys=<C-pageup>. mode=Normal. keybindings=normalModeKeyBindingsNonRecursiveMap. (at t.ConsoleForElectron.log (/home/ikigai/.vscode-insiders/extensions/vscodevim.vim-1.15.0/out/extension.js:9:355338))
4console.ts:137 [Extension Host] Remapper: verbose: key=<C-pageup>. keySlice=<C-pageup>. (at t.ConsoleForElectron.log (/home/ikigai/.vscode-insiders/extensions/vscodevim.vim-1.15.0/out/extension.js:9:355338))
console.ts:137 [Extension Host] ModeHandler: debug: handleKeyEvent('<C-pageup>') took 7ms (at t.ConsoleForElectron.log (/home/ikigai/.vscode-insiders/extensions/vscodevim.vim-1.15.0/out/extension.js:9:355338))
  • similary there exists <C-pagedown> too. I havent pressed that keybinding.

Video showing what is happening

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

Can you try doing the following when that happens:

  • On command palette (Ctrl+Shift+P) run Developer: Inspect Context Keys then click anywhere on the editor
  • Go to the developer tools console and open the object that showed up there
  • Check the following properties:

    • editorHasSelection

    • editorTextFocus

    • parameterHintsMultipleSignatures

    • suggestWidgetVisible

    • vim.active

    • vim.mode

    • vim.use<down>

    • vim.use<up>

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

@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.

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)".

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

elithrar picture elithrar  Â·  3Comments

waltiam picture waltiam  Â·  3Comments

st-schneider picture st-schneider  Â·  3Comments

cckowin picture cckowin  Â·  3Comments

stefanoio picture stefanoio  Â·  3Comments