File tree Expand file tree Collapse file tree 3 files changed +45
-8
lines changed Expand file tree Collapse file tree 3 files changed +45
-8
lines changed Original file line number Diff line number Diff line change @@ -608,18 +608,12 @@ impl App {
608
608
self . action_tx . send ( action) ?;
609
609
}
610
610
611
- // Update keymap if channel changed (remote control to channel mode transition)
612
- // This ensures channel-specific keybindings are properly loaded
611
+ // Update watch timer and history
613
612
if was_remote_control
614
613
&& matches ! ( action, Action :: ConfirmSelection )
615
614
&& self . television . mode == Mode :: Channel
615
+ || matches ! ( action, Action :: SwitchToChannel ( _) )
616
616
{
617
- self . update_input_map ( ) ;
618
- self . update_history ( ) ;
619
- self . restart_watch_timer ( ) ;
620
- } else if matches ! ( action, Action :: SwitchToChannel ( _) ) {
621
- // Channel changed via shortcut, refresh keymap and watch timer
622
- self . update_input_map ( ) ;
623
617
self . update_history ( ) ;
624
618
self . restart_watch_timer ( ) ;
625
619
}
Original file line number Diff line number Diff line change @@ -48,3 +48,24 @@ test_channel! {
48
48
test_channel_text: "text" ,
49
49
test_channel_diff: "git-diff" ,
50
50
}
51
+
52
+ #[ test]
53
+ fn test_channel_shortcuts ( ) {
54
+ let mut tester = PtyTester :: new ( ) ;
55
+ let mut child = tester
56
+ . spawn_command_tui ( tv_local_config_and_cable_with_args ( & [ "files" ] ) ) ;
57
+
58
+ tester. assert_tui_frame_contains ( "CHANNEL files" ) ;
59
+
60
+ // switch to the "dirs" channel
61
+ tester. send ( & f ( 2 ) ) ;
62
+ tester. assert_tui_frame_contains ( "CHANNEL dirs" ) ;
63
+
64
+ // switch back to the "files" channel
65
+ tester. send ( & f ( 1 ) ) ;
66
+ tester. assert_tui_frame_contains ( "CHANNEL files" ) ;
67
+
68
+ // Send Ctrl-C to exit
69
+ tester. send ( & ctrl ( 'c' ) ) ;
70
+ PtyTester :: assert_exit_ok ( & mut child, DEFAULT_DELAY * 2 ) ;
71
+ }
Original file line number Diff line number Diff line change @@ -339,6 +339,28 @@ pub fn ctrl(c: char) -> String {
339
339
( ( c as u8 & 0x1F ) as char ) . to_string ( )
340
340
}
341
341
342
+ pub fn f ( c : u8 ) -> String {
343
+ let seq = match c {
344
+ 1 => "\x1b OP" , // F1
345
+ 2 => "\x1b OQ" , // F2
346
+ 3 => "\x1b OR" , // F3
347
+ 4 => "\x1b OS" , // F4
348
+ 5 => "\x1b [15~" , // F5
349
+ 6 => "\x1b [17~" , // F6
350
+ 7 => "\x1b [18~" , // F7
351
+ 8 => "\x1b [19~" , // F8
352
+ 9 => "\x1b [20~" , // F9
353
+ 10 => "\x1b [21~" , // F10
354
+ 11 => "\x1b [23~" , // F11
355
+ 12 => "\x1b [24~" , // F12
356
+ _ => {
357
+ panic ! ( "Invalid function key: {}" , c) ;
358
+ }
359
+ } ;
360
+
361
+ seq. to_string ( )
362
+ }
363
+
342
364
pub const ENTER : & str = "\r " ;
343
365
pub const ESC : & str = "\x1b " ;
344
366
You can’t perform that action at this time.
0 commit comments