| 1 | package cli |
| 2 | |
| 3 | import ( |
| 4 | "slices" |
| 5 | "testing" |
| 6 | |
| 7 | "charm.land/bubbles/v2/textarea" |
| 8 | ) |
| 9 | |
| 10 | func TestComposerWordMotionAcceptsCtrlArrows(t *testing.T) { |
| 11 | ti := textarea.New() |
| 12 | configureChatTextarea(&ti) |
| 13 | |
| 14 | for _, tc := range []struct { |
| 15 | motion string |
| 16 | keys []string |
| 17 | ctrl string |
| 18 | alt string |
| 19 | }{ |
| 20 | {"forward", ti.KeyMap.WordForward.Keys(), "ctrl+right", "alt+right"}, |
| 21 | {"backward", ti.KeyMap.WordBackward.Keys(), "ctrl+left", "alt+left"}, |
| 22 | {"delete-backward", ti.KeyMap.DeleteWordBackward.Keys(), "ctrl+backspace", "alt+backspace"}, |
| 23 | } { |
| 24 | if !slices.Contains(tc.keys, tc.ctrl) { |
| 25 | t.Errorf("word %s is missing %s: %v", tc.motion, tc.ctrl, tc.keys) |
| 26 | } |
| 27 | if !slices.Contains(tc.keys, tc.alt) { |
| 28 | t.Errorf("word %s dropped %s: %v", tc.motion, tc.alt, tc.keys) |
| 29 | } |
| 30 | } |
| 31 | } |
| 32 |