GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Multiple extensions registering the 'type' command · Issue #13441 · microsoft/vscode

Multiple extensions registering the 'type' command #13441

New issue
Copy link
New issue
Copy link
Open
Open
Multiple extensions registering the 'type' command#13441
Copy link
Labels
apifeature-requestRequest for new features or functionalityRequest for new features or functionality
Milestone
Backlog

Description

@wmaurer
Wayne Maurer (wmaurer)
opened on Oct 10, 2016
Issue body actions
  • VSCode Version: 1.5.3
  • OS Version: Windows 10

Steps to Reproduce:

  1. Install and enable VSCodeVim and vscode-jumpy
  2. Open a file with text
  3. Run the command Jumpy Word Mode. Two letter decorations should appear at the start of each word
  4. Type in the two letter code for that word. Jumpy functionality should enact a 'Jump' to the cursor position of that decorator.
  5. It doesn't work :-( The keystrokes are being processed by VSCodeVim, not Jumpy.

I am the author of vscode-jumpy (repo). A user has reported that Jumpy does not work in combination with VSCodeVim: wmaurer/vscode-jumpy#1.

It seems that both extensions are doing a registerCommand('type'), but VSCodeVim seems to take priority over vscode-jumpy. Is there are way to manage which extension has priority, so that it can receive and process the keystrokes?
Ideally I want to Jumpy to receive and process the next two keystrokes after enabling Jumpy Word Mode, but then let the rest of the keystrokes forward to VSCodeVim.

Reacted by André Staltz, Yukai Huang, Dmitrii Babenko, kalaxiya, Kanitkorn Sujautra, Carter Anderson, Nicolas Mori, Marcus Vorwaller, Kuo-tung Kao, Anton Vasiljev and 45 more
Reacted by André Staltz, Kuo-tung Kao, Simon Babay, anthonychung14, Wayne Maurer, Max Sysoev, Travis Thieman, mgsergio, Helder S Ribeiro, James Proctor and 4 more

Activity

  1. Isidor Nikolic (isidorn)
    assigned
    Johannes Rieken (jrieken)
    on Oct 11, 2016
  2. Johannes Rieken (jrieken)
    assigned
    Alexandru Dima (alexdima)
    and unassigned
    Johannes Rieken (jrieken)
    on Oct 11, 2016
  3. alexdima commented on Oct 27, 2016

    @alexdima
    Alexandru Dima (alexdima)
    on Oct 27, 2016
    Member
    More actions

    We added registerCommand("type") especially to enable vim mode to be implemented from an extension. We didn't want to bake vim mode in the core, and there can be only one handler. We never considered typing being something collaborative (in this case between vscode-jumpy and VSCodeVim). Today, the last one wins.

    Reacted by goyalyashpal
  4. Alexandru Dima (alexdima)
    added
    feature-requestRequest for new features or functionalityRequest for new features or functionality
    api
    on Oct 27, 2016
  5. Alexandru Dima (alexdima)
    added this to the Backlog milestone on Oct 27, 2016
  6. Alexandru Dima (alexdima)
    removed their assignment
    on Oct 27, 2016
  7. samdesota commented on Nov 10, 2016

    @samdesota
    Sam DeSota (samdesota)
    on Nov 10, 2016
    More actions

    Could this be changed to something like ahandleKeys function? Something like:

    ...
    
    vscode.commands.registerCommand("start-mode", () => {
       // Latest attached handler receives the keys first.
       const subscription = vscode.handleKeys((evt) => {
         // event will bubble to the next handler if you don't cancel
         evt.stopPropagation()
       })   
    
       // End subscription to return the key priority to the previous holder.
       setTimeout(() => subscription.unsubscribe(), 3000)
    })

    Would really like to use vscode-jumpy, I imagine this would be fairly easy to implement?

  8. staltz commented on Nov 15, 2016

    @staltz
    André Staltz (staltz)
    on Nov 15, 2016
    More actions

    For what it's worth, Atom is able to handle both jumpy and vim emulation (and probably more).

  9. samdesota commented on Nov 15, 2016

    @samdesota
    Sam DeSota (samdesota)
    on Nov 15, 2016
    More actions

    alexandrudima I'd really like this feature, if you would point me in the right direction in the source and discuss a pull request I'd be glad to work on it.

  10. lucax88x commented on Mar 24, 2017

    @lucax88x
    Luca Trazzi (lucax88x)
    on Mar 24, 2017
    More actions

    I have the same precise issue by using my extension (codeacejumper)

  11. aratakokubun commented on Jul 3, 2017

    @aratakokubun
    aratakokubun (aratakokubun)
    on Jul 3, 2017
    More actions

    I would like to turn off vim keybinding while activating jumpy line or word mode.
    Is there any possible solution to do this? (ex: create a extension or set keymap)

  12. Shinikami commented on Jul 7, 2018

    @Shinikami
    Shinikami
    on Jul 7, 2018
    More actions

    Hey, all.
    May we have this issue updated, please?

    Reacted by Luca Trazzi, johnfarina, Simon Ho, Domi, Zachary Gibb and James Proctor
  13. wd commented on Nov 15, 2018

    @wd
    Dong Wang (wd)
    on Nov 15, 2018
    More actions

    It's has been 2 years, still can't get emacs-keymap work with ace-jump ext, does anyone have solution about this issue ?

    Reacted by johnfarina, geo t, xin-jin, anhnhoktvn, Travis Thieman, Helder S Ribeiro, Domi, Zachary Gibb, James Proctor, blair and 3 more
  14. thieman commented on Jan 21, 2019

    @thieman
    Travis Thieman (thieman)
    on Jan 21, 2019
    Contributor
    More actions

    If my reading of registerCommand is right, it already seems to implement the stack-like behavior we'd need for an extension to temporarily claim the type handler and then return it to the previous claimant (the Ace Jump usecase). https://github.com/Microsoft/vscode/blob/v1.19.3/src/vs/platform/commands/test/commands.test.ts#L25

    alexandrudima am I misunderstanding anything there?

    I think there is a separate use case worth discussing though, which is extensions that want to be notified when typing happens but do not need exclusive control over changes to the output buffer. These might be well-served by an onDidType event or similar, which I don't think is provided currently. Thoughts on that, as well?

    edit: I'm actually seeing references to an onDidType event that I didn't see in vscode.d.ts, I'll have to see if I can get to that

    Reacted by Domi
    Reacted by Domi
  15. Domiii commented on Feb 1, 2020

    @Domiii
    Domi (Domiii)
    on Feb 1, 2020
    More actions

    I like Travis Thieman (@thieman)'s ideas, especially (2):

    1. Change commands to execute the entire (already existing) stack of event handlers instead of only the top
      • Con: This is likely going to be a breaking change, since currently, type command handlers pass the ball by invoking the default:type command instead of communicating their intentions back to the caller
    2. Expose the onWillType and onDidType events to the Extension API
      • Pro: Its a very basic functionality to have for editor extensions
      • Also, here I have a question: I am guessing that such event handlers would use the same model of communication as the command engine, so it would probably not improve performance? (Performance problems have been reported many times, e.g. Overriding the default 'type' command and then calling the default 'type' command results in significantly slower execution time #65876 Extensions using the "type" command (for ex. Vim) have poor performance due to being single-threaded with other extensions #75627)
    Reacted by Robert Clover, Daniel Oliveira, James Proctor, druskus, tsra and blair
  16. arstnei0 commented on Feb 27, 2023

    @arstnei0
    tsra (arstnei0)
    on Feb 27, 2023
    More actions

    Why is this problem still not solved? It's a big problem right?

    Reacted by ten9miq, juhoha, tsra, Mitch Rivet, Ioannis Tsampras, TomFaulknerLC, Colin McNeil, jean-santos, Beau, Jose Browne and 5 more
  17. rgkirch commented on Nov 10, 2024

    @rgkirch
    rgkirch
    on Nov 10, 2024
    More actions

    Travis Thieman (@thieman) Alexandru Dima (@alexdima) If I copy that test into my extension then I get the error.

    This is what I put in my extension:

    		const command1 = function () { };
    		const command2 = function () { };
    		let reg1 = vscode.commands.registerCommand('foo', command1);
    		let reg2 = vscode.commands.registerCommand('foo', command2);
    		reg2.dispose();
    		reg1.dispose();
    

    IIUC, this is expected to work, right?

    This is what's in the test:

    	test('register/register/dispose', () => {
    		const command1 = function () { };
    		const command2 = function () { };
    
    		// dispose overriding command
    		let reg1 = CommandsRegistry.registerCommand('foo', command1);
    		assert.ok(CommandsRegistry.getCommand('foo')!.handler === command1);
    
    		let reg2 = CommandsRegistry.registerCommand('foo', command2);
    		assert.ok(CommandsRegistry.getCommand('foo')!.handler === command2);
    		reg2.dispose();
    
    		assert.ok(CommandsRegistry.getCommand('foo')!.handler === command1);
    		reg1.dispose();
    		assert.ok(CommandsRegistry.getCommand('foo') === undefined);
    

    Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    apifeature-requestRequest for new features or functionalityRequest for new features or functionality

    Type

    No type

    Projects

    No projects

      Milestone

      • BacklogNo due date

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.