Vim icon indicating copy to clipboard operation
Vim copied to clipboard

Visual line mode doesn't handle Up/Down arrow keys

Open oowekyala opened this issue 1 year ago • 2 comments

Describe the bug In visual line mode, Up and Down arrow keys are not handled and cause the cursor to move, but the Vim selection is not updated. This feels buggy and prevents me from using visual line mode. I use a keymap where j and k are not on the home row, but Up and Down are on the home row behind a modifier key.

To Reproduce Steps to reproduce the behavior:

  • Enter visual line mode (V)
  • Press down arrow

Expected behavior Down arrow should behave like j in Visual line mode, same for up arrow and k.

Screenshots Sorry I don't have screenshots

Log output:

024-06-02 18:46:44.528 [debug] Handling key: V
2024-06-02 18:46:44.529 [debug] Status bar: -- VISUAL LINE --
2024-06-02 18:46:45.014 [debug] Selection change: [101, 32], [101, 32], SelectionsLength: 1
2024-06-02 18:46:45.725 [debug] Selection change: [102, 32], [102, 32], SelectionsLength: 1
2024-06-02 18:46:48.695 [debug] Handling key: <left>
2024-06-02 18:46:49.162 [debug] Handling key: <right>

Here pressing the down key twice causes these "selection change" events, but no "Handling key" event. In the editor the selection moves down one line, but visual line is not exited. As you can see the right or left keys are handled by Vim. I would expect to see Handling key: <down> here.

Maybe this is related to these conditions in the package.json:

https://github.com/VSCodeVim/Vim/blob/9bab33c75d0a53873880a79c5d2de41c8be1bef9/package.json#L114-L122

Nothing I have tried in terms of remapping worked. I tried remapping down to j, and then directly within keybindings.json to extension.vim_down, but that didn't help.

Environment (please complete the following information):

  • Extension (VsCodeVim) version: v1.27.2
  • VSCode version: VSCodium 1.89.1
  • OS: Manjaro

Additional context Add any other context about the problem here.

oowekyala avatar Jun 02 '24 17:06 oowekyala

2024-06-04 10:10:55.308 [debug] Handling key: V
2024-06-04 10:10:55.310 [debug] Status bar: -- VISUAL LINE --
2024-06-04 10:10:56.467 [debug] Handling key: <down>
2024-06-04 10:10:56.869 [debug] Handling key: <down>
2024-06-04 10:10:57.475 [debug] Handling key: <up>
2024-06-04 10:10:57.885 [debug] Handling key: <up>
2024-06-04 10:10:59.948 [debug] Handling key: <Esc>
2024-06-04 10:10:59.950 [debug] Status bar: -- NORMAL --

I can do it here, is it caused by the configuration in settings. json?

HenryTSZ avatar Jun 04 '24 02:06 HenryTSZ

I reverted to the default settings.json and still have the problem. Here is the relevant part of my config:

    "vim.camelCaseMotion.enable": true,
    "vim.cursorStylePerMode.insert": "line",
    "vim.cursorStylePerMode.normal": "block",
    "vim.cursorStylePerMode.visual": "block",
    "vim.useCtrlKeys": false,
    "vim.useSystemClipboard": true,

and also

    "keyboard.dispatch": "keyCode",

(but reverting this one to its default value doesn't change the behavior either).

The down and up keys are also not handled by the Vim extension in other modes, eg

2024-06-04 18:55:52.912 [debug] Status bar: -- NORMAL --
2024-06-04 18:56:01.345 [debug] Selection change: [133, 31], [133, 31], SelectionsLength: 1
2024-06-04 18:56:01.345 [debug] Selections: Changing Cursors from selection handler... [133, 31], [133, 31]
2024-06-04 18:56:02.944 [debug] Selection change: [134, 31], [134, 31], SelectionsLength: 1
2024-06-04 18:56:02.944 [debug] Selections: Changing Cursors from selection handler... [134, 31], [134, 31]
2024-06-04 18:56:03.769 [debug] Handling key: <left>
2024-06-04 18:56:04.256 [debug] Handling key: <right>

In normal mode there are additional log lines as you can see

oowekyala avatar Jun 04 '24 17:06 oowekyala