Can't create new chords with the same start sequence as existing chords
Opened this issue · 0 comments
Steps to reproduce:
-
Create a chord
C-h x
for a commandRegex find and replace
. This chord is by convention as most text editors useC-h
forfind and replace
, and the addition of thex
invokes the optional regex find and replace. The chord UI accepts this definition and the chord works. -
Create another chord
C-h
for commandGlobal Search and Replace
. When prompted to type the chord, your chord input doesn't acceptC-h
and acts like it's in read only mode. -
Remove the
C-h x
chord. -
Define the
C-h
chord first, it is accepted and works fine. -
Try and define the
C-h-x
chord again. When prompted to type the chord, enterC-h x
. As soon as you type the comboC-h
, before you are able to type thex
, theGlobal Search and Replace
from theC-h
chord is invoked and that prevents you from typing the completeC-h x
chord.
Advice
-
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 coreHotkeysChordPlugin
class and import the other classes. -
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 yourChordCapture
function withdocument.removeEventListener("keydown", keydownhandler);
, but you may want to try modifying yourhandleKeyDown
function, because it has precedence over yourChordCapture
function forkeydown
events. -
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.