Skip to content

[BUG] Collection of bugs in combo logic #1107

@anoburn

Description

@anoburn

There are currently several bugs in the logic of the combo module (as mentioned on [Zulip](#KMK development > Combo behavior on key release).
For the test examples, I assume the default test layer from the combo unittests: [KC.A, KC.B, KC.C, KC.D, KC.E, KCMO, KC.F, KC.G] and the same general setup.

BUG 1

A small one: when match_coord=True and only a 0 remains for a combo (remaining = [0]), this will result in any(remaining) = False, triggering combos even though the 0-key has not been pressed. For example:

combos = [
    Chord((0, 1), KC.X, match_coord=True)
]

keyboard.test(
    'bug1',
    [
        (1, True),
        (1, False),
        t_after,
    ],
    [{KC.B}, {}],
)

The actual result is [{KC.X}, {}] because the 0 is not taken into consideration.

I've already fixed this one (see here, but hadn't opened a pull request so far because I was expecting a bigger rewrite for other things (see also the [Zulip post](#KMK development > Combo behavior on key release). I can still make a PR, if wished.

BUG 2

When two combos overlap and the first one is not completed, this will prohibit the second combo from triggering. For example:

combos = [
    Sequence((KC.A, KC.B, KC.C), KC.X),
    Sequence((KC.B, KC.D), KC.Y),
]

keyboard.test(
    'bug2',
    [
        (0, True), (0, False),
        t_within,
        (1, True), (1, False),
        t_within,
        (3, True), (3, False),
        t_after,
    ],
    [{KC.A}, {}, {KC.Y}, {}],
)

The actual result will be [{KC.A}, {}, {KC.B}, {}, {KC.D}, {}]

BUG 3

Combos don't trigger if typed too fast and another combo was still matching. For example:

combos.combos = [
    Chord((KC.A, KC.B), KC.X, timeout=3 * timeout),
    Chord((KC.A, KC.B, KC.C), KC.Y),
]
keyboard.test(
    'bug3',
    [
        (6, True),
        (7, True),
        (6, False),
        (7, False),
        t_after,
        (6, True),
        (7, True),
        (6, False),
        (7, False),
        3*t_after,
    ],
    [{KC.Z}, {}, {KC.Z}, {}]
)

The actual result are only the raw inputs, with no combos being activated {'A'}, {'A', 'B'}, {'B'}, {}, {'A'}, {'A', 'B'}, {'B'}, {}.
I guess one could argue this is intended behavior and is more of a feature request than a bug report, but this way combos are pretty much unusable when typing at higher speeds.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions