Skip to content

Commit cc04b8c

Browse files
sinelawclaude
andcommitted
Remove Ctrl+0-9 and Alt+Shift+0-9 macro keybindings
Terminals don't pass these key combinations correctly, so these bindings never worked in practice. Macros are still accessible via the command palette (Ctrl+P → Record/Play Macro). Updated tests to use the command palette flow instead of the removed shortcuts. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 153accb commit cc04b8c

3 files changed

Lines changed: 65 additions & 200 deletions

File tree

crates/fresh-editor/keymaps/default.json

Lines changed: 0 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -764,141 +764,6 @@
764764
"args": {},
765765
"when": "normal"
766766
},
767-
{
768-
"comment": "Normal context - Macros (Alt+Shift+0-9 to toggle recording)",
769-
"key": "0",
770-
"modifiers": ["alt", "shift"],
771-
"action": "toggle_macro_recording",
772-
"args": {"char": "0"},
773-
"when": "normal"
774-
},
775-
{
776-
"key": "1",
777-
"modifiers": ["alt", "shift"],
778-
"action": "toggle_macro_recording",
779-
"args": {"char": "1"},
780-
"when": "normal"
781-
},
782-
{
783-
"key": "2",
784-
"modifiers": ["alt", "shift"],
785-
"action": "toggle_macro_recording",
786-
"args": {"char": "2"},
787-
"when": "normal"
788-
},
789-
{
790-
"key": "3",
791-
"modifiers": ["alt", "shift"],
792-
"action": "toggle_macro_recording",
793-
"args": {"char": "3"},
794-
"when": "normal"
795-
},
796-
{
797-
"key": "4",
798-
"modifiers": ["alt", "shift"],
799-
"action": "toggle_macro_recording",
800-
"args": {"char": "4"},
801-
"when": "normal"
802-
},
803-
{
804-
"key": "5",
805-
"modifiers": ["alt", "shift"],
806-
"action": "toggle_macro_recording",
807-
"args": {"char": "5"},
808-
"when": "normal"
809-
},
810-
{
811-
"key": "6",
812-
"modifiers": ["alt", "shift"],
813-
"action": "toggle_macro_recording",
814-
"args": {"char": "6"},
815-
"when": "normal"
816-
},
817-
{
818-
"key": "7",
819-
"modifiers": ["alt", "shift"],
820-
"action": "toggle_macro_recording",
821-
"args": {"char": "7"},
822-
"when": "normal"
823-
},
824-
{
825-
"key": "8",
826-
"modifiers": ["alt", "shift"],
827-
"action": "toggle_macro_recording",
828-
"args": {"char": "8"},
829-
"when": "normal"
830-
},
831-
{
832-
"key": "9",
833-
"modifiers": ["alt", "shift"],
834-
"action": "toggle_macro_recording",
835-
"args": {"char": "9"},
836-
"when": "normal"
837-
},
838-
{
839-
"comment": "Macro playback (Ctrl+0-9)",
840-
"key": "0",
841-
"modifiers": ["ctrl"],
842-
"action": "play_macro",
843-
"args": {"char": "0"},
844-
"when": "normal"
845-
},
846-
{
847-
"key": "1",
848-
"modifiers": ["ctrl"],
849-
"action": "play_macro",
850-
"args": {"char": "1"},
851-
"when": "normal"
852-
},
853-
{
854-
"key": "2",
855-
"modifiers": ["ctrl"],
856-
"action": "play_macro",
857-
"args": {"char": "2"},
858-
"when": "normal"
859-
},
860-
{
861-
"key": "3",
862-
"modifiers": ["ctrl"],
863-
"action": "play_macro",
864-
"args": {"char": "3"},
865-
"when": "normal"
866-
},
867-
{
868-
"key": "4",
869-
"modifiers": ["ctrl"],
870-
"action": "play_macro",
871-
"args": {"char": "4"},
872-
"when": "normal"
873-
},
874-
{
875-
"key": "5",
876-
"modifiers": ["ctrl"],
877-
"action": "play_macro",
878-
"args": {"char": "5"},
879-
"when": "normal"
880-
},
881-
{
882-
"key": "6",
883-
"modifiers": ["ctrl"],
884-
"action": "play_macro",
885-
"args": {"char": "6"},
886-
"when": "normal"
887-
},
888-
{
889-
"key": "8",
890-
"modifiers": ["ctrl"],
891-
"action": "play_macro",
892-
"args": {"char": "8"},
893-
"when": "normal"
894-
},
895-
{
896-
"key": "9",
897-
"modifiers": ["ctrl"],
898-
"action": "play_macro",
899-
"args": {"char": "9"},
900-
"when": "normal"
901-
},
902767
{
903768
"key": "F5",
904769
"modifiers": [],

crates/fresh-editor/tests/e2e/smart_editing.rs

Lines changed: 64 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,42 @@ fn test_no_pair_delete_with_content_between() {
555555
// Macro Recording and Playback Tests
556556
// =============================================================================
557557

558+
/// Helper: open command palette, type a command, press Enter
559+
fn run_command(harness: &mut EditorTestHarness, command: &str) {
560+
harness
561+
.send_key(KeyCode::Char('p'), KeyModifiers::CONTROL)
562+
.unwrap();
563+
harness.render().unwrap();
564+
harness.type_text(command).unwrap();
565+
harness.render().unwrap();
566+
harness
567+
.send_key(KeyCode::Enter, KeyModifiers::NONE)
568+
.unwrap();
569+
harness.render().unwrap();
570+
}
571+
572+
/// Helper: start recording a macro via command palette ("Record Macro" → register digit)
573+
fn start_recording_macro(harness: &mut EditorTestHarness, register: char) {
574+
run_command(harness, "Record Macro");
575+
// The prompt asks for a register (0-9)
576+
harness.type_text(&register.to_string()).unwrap();
577+
harness
578+
.send_key(KeyCode::Enter, KeyModifiers::NONE)
579+
.unwrap();
580+
harness.render().unwrap();
581+
}
582+
583+
/// Helper: play a macro via command palette ("Play Macro" → register digit)
584+
fn play_macro_via_palette(harness: &mut EditorTestHarness, register: char) {
585+
run_command(harness, "Play Macro");
586+
// The prompt asks for a register (0-9)
587+
harness.type_text(&register.to_string()).unwrap();
588+
harness
589+
.send_key(KeyCode::Enter, KeyModifiers::NONE)
590+
.unwrap();
591+
harness.render().unwrap();
592+
}
593+
558594
/// Test starting and stopping macro recording
559595
#[test]
560596
fn test_macro_recording_toggle() {
@@ -565,11 +601,8 @@ fn test_macro_recording_toggle() {
565601
let mut harness = harness_with_auto_indent();
566602
harness.open_file(&file_path).unwrap();
567603

568-
// Start recording macro 0 with Alt+Shift+0
569-
harness
570-
.send_key(KeyCode::Char('0'), KeyModifiers::ALT | KeyModifiers::SHIFT)
571-
.unwrap();
572-
harness.render().unwrap();
604+
// Start recording macro 0 via command palette
605+
start_recording_macro(&mut harness, '0');
573606

574607
// Verify recording state through status message
575608
let status = harness
@@ -583,11 +616,8 @@ fn test_macro_recording_toggle() {
583616
status
584617
);
585618

586-
// Stop recording by toggling again (Alt+Shift+0)
587-
harness
588-
.send_key(KeyCode::Char('0'), KeyModifiers::ALT | KeyModifiers::SHIFT)
589-
.unwrap();
590-
harness.render().unwrap();
619+
// Stop recording by toggling again via command palette
620+
start_recording_macro(&mut harness, '0');
591621

592622
let status = harness
593623
.editor()
@@ -614,11 +644,8 @@ fn test_macro_record_and_playback() {
614644
// Position at beginning of line 1
615645
harness.send_key(KeyCode::Home, KeyModifiers::NONE).unwrap();
616646

617-
// Start recording macro 1
618-
harness
619-
.send_key(KeyCode::Char('1'), KeyModifiers::ALT | KeyModifiers::SHIFT)
620-
.unwrap();
621-
harness.render().unwrap();
647+
// Start recording macro 1 via command palette
648+
start_recording_macro(&mut harness, '1');
622649

623650
// Record actions: go to end of line, type "!"
624651
harness.send_key(KeyCode::End, KeyModifiers::NONE).unwrap();
@@ -628,10 +655,8 @@ fn test_macro_record_and_playback() {
628655
harness.send_key(KeyCode::Down, KeyModifiers::NONE).unwrap();
629656
harness.send_key(KeyCode::Home, KeyModifiers::NONE).unwrap();
630657

631-
// Stop recording by toggling again (Alt+Shift+1)
632-
harness
633-
.send_key(KeyCode::Char('1'), KeyModifiers::ALT | KeyModifiers::SHIFT)
634-
.unwrap();
658+
// Stop recording with F5
659+
harness.send_key(KeyCode::F(5), KeyModifiers::NONE).unwrap();
635660
harness.render().unwrap();
636661

637662
let content = harness.get_buffer_content().unwrap();
@@ -642,11 +667,8 @@ fn test_macro_record_and_playback() {
642667
content
643668
);
644669

645-
// Play macro 1 with Ctrl+1 to process line2
646-
harness
647-
.send_key(KeyCode::Char('1'), KeyModifiers::CONTROL)
648-
.unwrap();
649-
harness.render().unwrap();
670+
// Play macro 1 via command palette to process line2
671+
play_macro_via_palette(&mut harness, '1');
650672

651673
let content = harness.get_buffer_content().unwrap();
652674
// line2 should now have "!" appended
@@ -657,10 +679,7 @@ fn test_macro_record_and_playback() {
657679
);
658680

659681
// Play macro again for line3
660-
harness
661-
.send_key(KeyCode::Char('1'), KeyModifiers::CONTROL)
662-
.unwrap();
663-
harness.render().unwrap();
682+
play_macro_via_palette(&mut harness, '1');
664683

665684
let content = harness.get_buffer_content().unwrap();
666685
// line3 should now have "!" appended
@@ -681,11 +700,8 @@ fn test_multiple_macro_slots() {
681700
let mut harness = harness_with_auto_indent();
682701
harness.open_file(&file_path).unwrap();
683702

684-
// Record macro in slot 5
685-
harness
686-
.send_key(KeyCode::Char('5'), KeyModifiers::ALT | KeyModifiers::SHIFT)
687-
.unwrap();
688-
harness.render().unwrap();
703+
// Record macro in slot 5 via command palette
704+
start_recording_macro(&mut harness, '5');
689705

690706
let status = harness
691707
.editor()
@@ -700,13 +716,11 @@ fn test_multiple_macro_slots() {
700716

701717
// Stop recording
702718
harness.send_key(KeyCode::F(5), KeyModifiers::NONE).unwrap();
703-
704-
// Record macro in slot 9
705-
harness
706-
.send_key(KeyCode::Char('9'), KeyModifiers::ALT | KeyModifiers::SHIFT)
707-
.unwrap();
708719
harness.render().unwrap();
709720

721+
// Record macro in slot 9 via command palette
722+
start_recording_macro(&mut harness, '9');
723+
710724
let status = harness
711725
.editor()
712726
.get_status_message()
@@ -731,13 +745,8 @@ fn test_play_nonexistent_macro() {
731745
let mut harness = harness_with_auto_indent();
732746
harness.open_file(&file_path).unwrap();
733747

734-
// Try to play macro 8 (which was never recorded)
735-
// Note: We use 8 instead of 7 because Ctrl+7 is now mapped to toggle_comment
736-
// (as the terminal equivalent of Ctrl+/)
737-
harness
738-
.send_key(KeyCode::Char('8'), KeyModifiers::CONTROL)
739-
.unwrap();
740-
harness.render().unwrap();
748+
// Try to play macro 8 (which was never recorded) via command palette
749+
play_macro_via_palette(&mut harness, '8');
741750

742751
let status = harness
743752
.editor()
@@ -765,11 +774,8 @@ fn test_toggle_macro_recording() {
765774
let mut harness = harness_with_auto_indent();
766775
harness.open_file(&file_path).unwrap();
767776

768-
// Toggle ON - start recording
769-
harness
770-
.send_key(KeyCode::Char('2'), KeyModifiers::ALT | KeyModifiers::SHIFT)
771-
.unwrap();
772-
harness.render().unwrap();
777+
// Toggle ON - start recording via command palette
778+
start_recording_macro(&mut harness, '2');
773779

774780
let status = harness
775781
.editor()
@@ -782,11 +788,8 @@ fn test_toggle_macro_recording() {
782788
status
783789
);
784790

785-
// Toggle OFF - stop recording
786-
harness
787-
.send_key(KeyCode::Char('2'), KeyModifiers::ALT | KeyModifiers::SHIFT)
788-
.unwrap();
789-
harness.render().unwrap();
791+
// Toggle OFF - toggle same register via command palette
792+
start_recording_macro(&mut harness, '2');
790793

791794
let status = harness
792795
.editor()
@@ -811,11 +814,8 @@ fn test_macro_recording_hint_shows_correct_keybinding() {
811814
let mut harness = harness_with_auto_indent();
812815
harness.open_file(&file_path).unwrap();
813816

814-
// Start recording macro 1 using Alt+Shift+1
815-
harness
816-
.send_key(KeyCode::Char('1'), KeyModifiers::ALT | KeyModifiers::SHIFT)
817-
.unwrap();
818-
harness.render().unwrap();
817+
// Start recording macro 1 via command palette
818+
start_recording_macro(&mut harness, '1');
819819

820820
// Get the status message
821821
let status = harness
@@ -862,9 +862,11 @@ fn test_macro_recording_hint_shows_correct_keybinding() {
862862
status_after
863863
);
864864

865-
// The saved message should also contain a play hint mentioning command palette
865+
// The saved message should also contain a play hint mentioning F4 or command palette
866866
assert!(
867-
status_after.contains("Ctrl+P") || status_after.contains("Play"),
867+
status_after.contains("Ctrl+P")
868+
|| status_after.contains("Play")
869+
|| status_after.contains("F4"),
868870
"Saved message should mention how to play macro, got: {}",
869871
status_after
870872
);

docs/features/editing.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,10 @@ Record and replay sequences of keystrokes:
8686

8787
| Shortcut | Action |
8888
|----------|--------|
89-
| `Alt+Shift+0-9` | Toggle macro recording for slot 0-9 |
90-
| `Ctrl+0-9` | Play macro from slot 0-9 |
9189
| `F5` | Stop macro recording |
9290
| `F4` | Play last recorded macro |
9391

94-
You can also use the command palette (`Ctrl+P`) to access **Record Macro**, **Play Macro**, **Play Last Macro**, and **List Macros** commands.
92+
Use the command palette (`Ctrl+P`) to access **Record Macro**, **Play Macro**, **Play Last Macro**, and **List Macros** commands.
9593

9694
## Bookmarks
9795

0 commit comments

Comments
 (0)