Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vim vscode extension #5125

Closed
kanatohodets opened this issue May 12, 2019 · 6 comments
Closed

vim vscode extension #5125

kanatohodets opened this issue May 12, 2019 · 6 comments
Labels
bug bugs found in the application vim issues related to vim vscode issues related to VSCode compatibility

Comments

@kanatohodets
Copy link

Description

The extension for Vim emulation in VSCode quickly crashes in Theia, for at least two reasons. Likely related to #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 dd9eb6b (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!

@kanatohodets
Copy link
Author

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.

@akosyakov
Copy link
Member

Not all monaco commands are exposed for VS Code extensions yet. You will need to wait till #4247 is done.

@akosyakov akosyakov added bug bugs found in the application vim issues related to vim vscode issues related to VSCode compatibility labels May 13, 2019
@kanatohodets
Copy link
Author

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

@akosyakov
Copy link
Member

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.

@hiredgunhouse
Copy link

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

@kanatohodets
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug bugs found in the application vim issues related to vim vscode issues related to VSCode compatibility
Projects
None yet
Development

No branches or pull requests

3 participants