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

Can't create new chords with the same start sequence as existing chords #4

Open
bradykelly opened this issue Oct 7, 2023 · 0 comments

Comments

@bradykelly
Copy link

bradykelly commented Oct 7, 2023

Steps to reproduce:

  1. Create a chord C-h x for a command Regex find and replace. This chord is by convention as most text editors use C-h for find and replace, and the addition of the x invokes the optional regex find and replace. The chord UI accepts this definition and the chord works.

  2. Create another chord C-h for command Global Search and Replace. When prompted to type the chord, your chord input doesn't accept C-h and acts like it's in read only mode.

  3. Remove the C-h x chord.

  4. Define the C-h chord first, it is accepted and works fine.

  5. Try and define the C-h-x chord again. When prompted to type the chord, enter C-h x. As soon as you type the combo C-h, before you are able to type the x, the Global Search and Replace from the C-h chord is invoked and that prevents you from typing the complete C-h x chord.

Advice

  1. I haven't properly reviewed your code yet as it's too untidy for me this early in the morning, but separate classes should be placed in separate files, as should functions outside of classes. The main.ts file should basically only contain the core HotkeysChordPlugin class and import the other classes.

  2. It shouldn't be too hard to suspend chord processing while the Type the chord input has focus? It seems you may have tried to cover this in your ChordCapture function with document.removeEventListener("keydown", keydownhandler);, but you may want to try modifying your handleKeyDown function, because it has precedence over your ChordCapture function for keydown events.

  3. Any way you do it, you should ignore chord events while the user is typing in a chord definition in your plugin UI, but I'm not certain about how you should do this yet. If it comes to me when I wake up more I may put in a PR.

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

No branches or pull requests

1 participant