Skip to content
Myr

change(keys): spacebar sends a `KeySpace` (#315)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* Revert "fix: update tests for space input" This reverts commit bfb166822e998df6c8c15a9b56ae7cfc9d8bfff8. * Revert "feat: obliterate type KeySpace" This reverts commit d3fb1b707a27c6df66cb97647a902c2f110eee39.

authored by Christian Rocha · committed by GitHub · parent bfb1668 · Browse files · 2 files+13 added−7 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+13 added−7 removed

  • other:+13 added−7 removed

2 files+13 added−7 removed

modified:key_test.go+3 added-7 removed
6 unmodified lines
78func TestKeyString(t *testing.T) {9 t.Run("alt+space", func(t *testing.T) {10 if got := KeyMsg(Key{11 Type: KeyRunes,12 Runes: []rune{' '},13 Alt: true,11 Type: KeySpace,12 Alt: true,13 }).String(); got != "alt+ " {14 t.Fatalf(`expected a "alt+ ", got %q`, got)15 }16 })
17 unmodified lines
34}3536func TestKeyTypeString(t *testing.T) {37 t.Run("space", func(t *testing.T) {39 if got := KeyMsg(Key{40 Type: KeyRunes,41 Runes: []rune{' '},42 }).String(); got != " " {38 if got := KeySpace.String(); got != " " {39 t.Fatalf(`expected a " ", got %q`, got)40 }41 })42
35 unmodified lines
modified:key.go+10 added
196 unmodified lines
197 KeyEnd198 KeyPgUp199 KeyPgDown200 KeyDelete201 KeySpace202 KeyCtrlUp203 KeyCtrlDown204 KeyCtrlRight205 KeyCtrlLeft
68 unmodified lines
274 KeyRunes: "runes",275 KeyUp: "up",276 KeyDown: "down",277 KeyRight: "right",278 KeySpace: " ", // for backwards compatibility279 KeyLeft: "left",280 KeyShiftTab: "shift+tab",281 KeyHome: "home",282 KeyEnd: "end",
270 unmodified lines
553 KeyMsg(Key{Type: r}),554 }, nil555 }556557 // If it's a space, override the type with KeySpace (but still include the558 // rune).559 if runes[0] == ' ' {560 return []Msg{561 KeyMsg(Key{Type: KeySpace, Runes: runes}),562 }, nil563 }564565 // Welp, it's just a regular, ol' single rune.566 return []Msg{567 KeyMsg(Key{Type: KeyRunes, Runes: runes}),568 }, nil
1 unmodified line