VSCodeVim / Vim

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

extension.vim_escape command doesn't work #6107

Open mattuylee opened 3 years ago

mattuylee commented 3 years ago

Describe the bug the command "extension.vim_escape" doesn't work since version 1.18.0, and falling back to version 1.16.0 could fix this.

To Reproduce

  1. Install VSCode(I use VSCodium but it should not matter)
  2. Install VSCodeVim (version >= 1.18.0)
  3. Open Settings in json mode, edit settings.json like following:
    {
        "vim.insertModeKeyBindings": [
            {
                "before": [
                    "<C-i>"
                ],
                "commands": [
                    // some other commands (optional)
                    "extension.vim_escape"
                ]
            }
        ]
    }
  4. Save settings.json, and enter i to get into insert mode, then enter Control + I
  5. Vim mode should change to normal mode, but nothing occurs (I am sure the command is emitted)

Expected behavior Vim mode should change to normal mode.

Environment (please complete the following information):

J-Fields commented 3 years ago

Try this instead:

{
    "vim.insertModeKeyBindings": [
        {
            "before": [
                "<C-i>"
            ],
            "after": [
                "<Esc>"
            ]
        }
    ]
}
mattuylee commented 3 years ago

Try this instead:

{
    "vim.insertModeKeyBindings": [
        {
            "before": [
                "<C-i>"
            ],
            "after": [
                "<Esc>"
            ]
        }
    ]
}

But how can I execute some commands such as hide intelligence suggestion at the same time?

Since command extension.vim_escape works in previous versions, I think this is a bug, probably.

J-Fields commented 3 years ago

Does mapping with <Esc> not close intellisense suggestions?

statiolake commented 3 years ago

I'm also having this issue. Currently reflow (gq) doesn't work well with multibyte characters (https://github.com/VSCodeVim/Vim/issues/2686), so I want to run rewrap.rewrapComment command provided by Rewrap extension with gq. The following setting

  "vim.visualModeKeyBindings": [
    {
      "before": ["g", "q"],
      "commands": ["rewrap.rewrapComment"]
    }
  ],

does reflow text as expected, but after reflowing it's still in visual mode. I want to cancel the visual mode (as in Vim) so I tried executing extension.vim_escape in this bindings:

  "vim.visualModeKeyBindings": [
    {
      "before": ["g", "q"],
      "commands": [
        "rewrap.rewrapComment",
        "extension.vim_escape"
      ]
    }
  ],

but unfortunately this didn't cancel visual mode.

(May not related but) interestingly, running cancelSelectionextension.vim_escape combo twice

  "vim.visualModeKeyBindings": [
    {
      "before": ["g", "q"],
      "commands": [
        "rewrap.rewrapComment",
        "cancelSelection",
        "extension.vim_escape",
        "cancelSelection",
        "extension.vim_escape"
      ]
    }
  ],

once removes selection in appearance, but still in visual mode (moving cursor again produces the visual selection as if nothing had happened).

mattuylee commented 3 years ago

Does mapping with <Esc> not close intellisense suggestions?

Yeah it does. But it doesn't close parameter hints which command closeParameterHints does.

Well, I have other solution to adapt to this. But in my opinion, providing command extension.vim_escape makes the configuration much more flexible. Since it has been implemented in previous version, why not fix it in current version?

J-Fields commented 3 years ago

Since it has been implemented in previous version, why not fix it in current version?

Fair enough, I'll re-open, though I'm not sure if this is explicitly supported.

But it doesn't close parameter hints which command closeParameterHints does.

Can you explain exactly what you mean by "parameter hints"? This sounds like something <Esc> should handle by default.

mattuylee commented 3 years ago

Thank you very much.

This sounds like something should handle by default.

Yes. pressing Esc will close parameter hints. But if you want to change vim mode to normal at same time, you have to press Esc twice. And, Esc is too far.

Can you explain exactly what you mean by "parameter hints"?

The following two gif pics describe the problem that it doesn't close parameter hints.

In this picture, I mapped Ctrl+i to Esc, and after the parameter hint appears, I pressed Ctrl+i: does-not-work

But what interests me is, if there is no character between the parentheses, it works normally. In this picture, I didn't change any config: works

So I have to use a command to make it work in any case:

{
  // setting.json
  "vim.insertModeKeyBindings": [
    {
      "before": ["<C-i>"],
      // "after": ["<Esc>"],
      "commands": [
        "closeParameterHints",
        "extension.vim_escape"
      ]
    }
  ]
}
J-Fields commented 3 years ago

Hmm, all this works for me, even when mapping <C-i> to <Esc>. We started explicitly closing parameter hints in https://github.com/VSCodeVim/Vim/commit/1a55f891c7364ba705654a3dc815d4f36cd8d749

J-Fields commented 3 years ago

Would you mind posting the rest of your settings, please?

mattuylee commented 3 years ago

I am sorry for that. It's my fault because I am using an obsolete version which was released at on July 2020.

In my case now I can just map <C-i> to <Esc>. But the command extension.vim_escapse still not works. Maybe this feature is also needed somewhere else such as for statiolake's case. I hope it could be fixed if it won't take too much effort.

mattuylee commented 3 years ago

By the way, the reason why I am using an old version is, after v1.16.0, mapping yank(copy) action to the global clipboard doesn't work.

Try the following to reproduce:

// settings.json
{
  "vim.visualModeKeyBindings": [
    {
      "before": ["y"],
      "after": ["\"", "+", "y"]
    }
  ]
}

When I press y in visual mode, the extension will lose response for any key input.

Er, should I open a new issue instead?