Fix <Space> binds

```
Number(' ') === 0
```

js needs to be nuked from orbit
This commit is contained in:
Oliver Blanthorn 2026-06-10 12:54:12 +02:00
parent ecdb3338fe
commit dbed660872
No known key found for this signature in database
GPG key ID: 2BB8C36BB504BFF3
2 changed files with 16 additions and 2 deletions

View file

@ -136,6 +136,12 @@ function mk(k, mod?: ks.KeyModifiers) {
[[[mk("o")], keymap2], { value: "bar", isMatch: true }],
[[mks("goff"), keymap2], { keys: [], isMatch: false }],
[[mks("xxxxx"), keymap2], { keys: [], isMatch: false }],
// Space key should be bindable via <Space>
[
[[mk(" ")], new Map([[mks("<Space>"), "spacetest"]])],
{ value: "spacetest", isMatch: true },
],
])
testAllObject(ks.completions, [
@ -144,6 +150,11 @@ function mk(k, mod?: ks.KeyModifiers) {
// -ve tests
[[mks("x"), keymap], new Map()],
[[mks("ggg"), keymap], new Map()],
// Space key completions
[
[[mk(" ")], new Map([[mks("<Space>"), "spacetest"]])],
new Map([[mks("<Space>"), "spacetest"]]),
],
])
} // }}}
@ -156,6 +167,7 @@ testAll(ks.bracketexprToKey, [
["<M-a>b", [mk("a", { metaKey: true }), "b"]],
["<S-Escape>b", [mk("Escape", { shiftKey: true }), "b"]],
["<Tab>b", [mk("Tab"), "b"]],
["<Space>b", [mk(" "), "b"]],
["<>b", [mk("<"), ">b"]],
["<tag >", [mk("<"), "tag >"]],
])
@ -790,6 +802,9 @@ testAllObject(ks.mapstrToKeyseq, [
],
],
["wat's up <s-Escape>", mks("wat's up <s-Escape>")],
// <Space> should produce a minimal key with key=" "
["<Space>", [mk(" ", { keydown: true })]],
])
// Check order of modifiers doesn't matter

View file

@ -189,8 +189,7 @@ export interface ParserResponse {
numericPrefix?: number
}
const isDigit = (d: string) =>
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9].includes(Number(d))
const isDigit = (d: string) => d.length === 1 && d >= "0" && d <= "9"
const isKeyup = (k: MinimalKey) => k.keyup