GeezerVison is showing github.com — Multiple extensions registering the 'type' command · Issue #13441 · microsoft/vscode
Multiple extensions registering the 'type' command #13441Description
- VSCode Version: 1.5.3
- OS Version: Windows 10
Steps to Reproduce:
- Install and enable VSCodeVim and vscode-jumpy
- Open a file with text
- Run the command
Jumpy Word Mode. Two letter decorations should appear at the start of each word
- Type in the two letter code for that word. Jumpy functionality should enact a 'Jump' to the cursor position of that decorator.
- 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 Activityalexdima commented on Oct 27, 2016 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. samdesota commented on Nov 10, 2016 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? staltz commented on Nov 15, 2016 For what it's worth, Atom is able to handle both jumpy and vim emulation (and probably more). samdesota commented on Nov 15, 2016 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. lucax88x commented on Mar 24, 2017 I have the same precise issue by using my extension (codeacejumper) aratakokubun commented on Jul 3, 2017 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) Shinikami commented on Jul 7, 2018 Hey, all.
May we have this issue updated, please? Reacted by Luca Trazzi, johnfarina, Simon Ho, Domi, Zachary Gibb and James Proctor wd commented on Nov 15, 2018 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 thieman commented on Jan 21, 2019 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 Domiii commented on Feb 1, 2020 I like Travis Thieman (@thieman)'s ideas, especially (2):
- 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
- Expose the
onWillType and onDidType events to the Extension API
Reacted by Robert Clover, Daniel Oliveira, James Proctor, druskus, tsra and blair arstnei0 commented on Feb 27, 2023 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 rgkirch commented on Nov 10, 2024 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.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|