Theia: vim vscode extension

Created on 12 May 2019  路  6Comments  路  Source: eclipse-theia/theia

Description

The extension for Vim emulation in VSCode quickly crashes in Theia, for at least two reasons. Likely related to https://github.com/theia-ide/theia/issues/4247.

Misaligned command name for editor.action.insertLineAfter

Out of the box some basic navigation works, like 'hjkl' based movement. However, switching to insert mode using o (for 'insert line after cursor') crashes:

root ERROR [hosted-plugin: 16788] TaskQueue: error: Error running task. Failed to handle key=o. The command 'editor.action.insertLineAfter' cannot be executed. There are no active handlers available for the command..

After some strategic console.warn additions, I understood that Theia was registering a command monaco.editor.action.insertLineAfter, so I did a quick hack in packages/core/src/common/command.ts executeCommand() to prefix any editor.* command with monaco. before looking it up in the command registry.

Missing command name for default:type

With that hack, o would successfully insert a line after the cursor and switch to insert mode. However, any typing in edit mode resulted in the following:

TaskQueue: Error running task. Failed to handle key=a. The command 'default:type' cannot be executed. There are no active handlers available for the command. (args: [{"text":"a"}]).

The same is observable by entering insert mode using i, which does not require the monaco.editor.* command ID hack to reproduce.

I searched for the corresponding Theia command to default:type so I could put another hack in place and keep testing, but it seems to me that Theia does not use a command for basic text entry, and I wasn't able to figure out how exactly button press events turn into text insertion, so that's as far as I got.

Reproduction Steps

  1. Create plugins directory, place vscodevim.vim-1.8.0.vsix inside it.
  2. cd examples/browser && yarn run start
  3. Open Theia in browser, open a file, select the text area, press o. Or, press i, followed by any letter.

OS and Theia version:
Ubuntu 18.04 - Theia dd9eb6b62419187dbd2616bb747fd7b321502019 (HEAD on master as of submission). Running the browser example with a plugins directory containing the vim extension.

Diagnostics:
Using node v11.9.0.

By the way, this looks like a stellar project, and I'm very excited about it!

bug vim vscode

Most helpful comment

Would love to use Theia, but lack of Vim emulation is a deal breaker for me :/

All 6 comments

Follow up after a bit more digging:

Regarding editor.action.insertLineAfter

I see that the DebugConfigurationManager uses editor.action.insertLineAfter. I'm not sure why this works (I tested it by adding some debugger configurations under the Chrome debugger), but the vim extension does not.

Regarding default:type

I decided to test my understanding of the codebase by creating a plugin that provided the default:type command. This worked: the vim extension stopped crashing on text insertion, but I stalled out trying to figure out how to get the context required to translate the arguments to the default:type command to something acceptable to workspace.applyEdit. I'm not sure that workspace.applyEdit is the right API to programmatically 'type' some characters, but I couldn't find anything more likely than that.

The default:type argument is pretty basic, just: [{text: "z"}] if z is pressed.

After a bit more reading, it seemed like this is the kind of command API compatibility thing that makes sense to register in PluginVsCodeCommandsContribution. So I'm currently trying to figure out how to get the right context to feed to a workspace.applyEdit call from a default:type command handler in PluginVsCodeCommandsContribution.

Not all monaco commands are exposed for VS Code extensions yet. You will need to wait till https://github.com/theia-ide/theia/issues/4247 is done.

Ok, makes sense. Do you understand why editor.action.insertLineAfter is usable by the DebugConfigurationManager? Are these two different scopes of command registration?

DebugConfigurationManager uses Monaco directly in the same process on the frontend, VS Code extensions are running in another process on the backend not all commands are available to them.

Would love to use Theia, but lack of Vim emulation is a deal breaker for me :/

I tested it out today, and the VSCode vim extension was working great! Awesome work!

Makes sense that there are perf issues given the design of the VSCode Vim plugin, but that's outside the scope of this issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vince-fugnitto picture vince-fugnitto  路  3Comments

dhananjayharel picture dhananjayharel  路  3Comments

jeanlucburot picture jeanlucburot  路  3Comments

Beetix picture Beetix  路  3Comments

vinokurig picture vinokurig  路  3Comments