Skip to content

vscode: fix vscode-vim keybindings conflict - #3308

Merged
bors[bot] merged 1 commit into
rust-lang:masterfrom
Veetaha:fix/vscode-on-enter-for-vim
Feb 27, 2020
Merged

bors[bot] merged 1 commit into
rust-lang:masterfrom
Veetaha:fix/vscode-on-enter-for-vim

Conversation

@Veetaha

@Veetaha Veetaha commented Feb 25, 2020 •

Copy link
Copy Markdown
Contributor

Closes #3013 I hope

vscode-vim extension overrides the type command so that it prevents
some keypresses to reach the text document editor.
It conflicts with our onEnter keybinding
that is used to support automatic doc comments extending and
indentation insertion.

The VSCode-native way to implement this would be
to use regular expressions, but as per matklad it is
considered not acceptable for the language server.

Thus we implement it via a Enter keybinding that
invokes our onEnter command which does it via the language-server.

At the end of the day we may only apply
ad hoc workarounds for conflicting extensions.
But vscode has another bug for that. You
either cannot use parantheses in when condition
of a keybinding or it just malfunctions.

See an issue about that here: microsoft/vscode#91473
To get the ultimate context, follow this zulip thread

vscode-vim extension overrides the `type` command so that it prevents
some keypresses to reach the text document editor.
It conflicts with our `onEnter` keybinding
that is used to support automatic doc comments extending and
indentation insertion.

The VSCode-native way to implement this would be
to use regular expressions, but as per matklad it is
considered not acceptable for the language server.

Thus we implement it via a `Enter` keybinding that
invokes our `onEnter` command which sends
a request to rust-analyzer process and applies
the appropriate source change recieved from it.

At the end of the day we may only apply
ad hoc workarounds for conflicting extensions.
But vscode has another bug for that. You
either cannot use parantheses in `when` condition
of a keybinding or it just malfunctions.

See an issue about that here: microsoft/vscode#91473
To get the ultimate context, follow this zulip thread: https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/Enhanced.20typing
@Veetaha
Veetaha requested review from lnicola and matklad February 25, 2020 21:24
@lnicola

lnicola commented Feb 25, 2020

Copy link
Copy Markdown
Member

Can we involve someone from the Vim extension? Maybe there's a way to detect the search mode.

@lnicola

lnicola commented Feb 25, 2020

Copy link
Copy Markdown
Member

@johnfn Sorry to ping you for this, but we could use a bit of help here. We're an LSP extension for the Rust language, and we handle onEnter for some extra features like handling block comments (with the caveats in microsoft/vscode#65876).

This conflicts with the Vim extension and we're trying to avoid that with the changes here. But one issue is that our command still triggers when searching text (with /). Is there a way to detect that?

@johnfn

johnfn commented Feb 25, 2020 •

Copy link
Copy Markdown

Ah, that's pretty rough. We had to implement / in the way we did because at the time there was no way to query the user for input while also live updating the IDE with the results of that input as the user types.

The best way would be to rewrite that section of vscodevim to use a better strategy to gather input from the user and update live (if such an API even exists??). I realize that's kind of a tall order though.

I'd imagine you could also do some sort of inter-extension communication - it's a hack but it would work. I don't have enough time to maintain vscodevim any more, unfortunately :( but I'm sure if you asked around on our Slack that someone might be able to help you out.

@Veetaha

Veetaha commented Feb 26, 2020

Copy link
Copy Markdown
Contributor Author

Thanks for the answer!
I think we can merge this. The search is triggered from the normal mode so the newline is not inserted onEnter (i.e. vim is still not in insert mode), so it should work!

@lnicola

lnicola commented Feb 26, 2020 •

Copy link
Copy Markdown
Member

It does insert a newline for me IIRC (unless it's a different condition than the one I've tested). Do you happen to know where that vim.mode value comes from?

At least this is an improvement, right?

@Veetaha

Veetaha commented Feb 26, 2020

Copy link
Copy Markdown
Contributor Author

Yeah, I saw the source code of vscode-vim, so I can tell. Might I ask you for steps to reproduce @lnicola ?

@lnicola

lnicola commented Feb 26, 2020

Copy link
Copy Markdown
Member

@Veetaha never mind, it's working for me this time. I think editing the condition didn't work for me, since it added that binding some 20 times to the JSON.

@matklad

matklad commented Feb 27, 2020

Copy link
Copy Markdown
Contributor

bors r+

@bors

bors Bot commented Feb 27, 2020

Copy link
Copy Markdown
Contributor

@bors
bors Bot merged commit 04b3bd5 into rust-lang:master Feb 27, 2020
bors Bot added a commit that referenced this pull request Oct 1, 2021
10416: docs: add note about `vscode-vim` in `on_enter` r=lnicola a=7596ff

I found myself search for this, so building off of #3013 and #3308, I
hope this note is useful.


Co-authored-by: Cassandra McCarthy <[email protected]>
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 this pull request may close these issues.

enableEnhancedTyping might be broken, vscode-vim issues

4 participants