@@ -87,11 +87,9 @@ fn run() -> apperr::Result<()> {
8787 // As such, we call this after `handle_args`.
8888 sys:: switch_modes ( ) ?;
8989
90- let mut vt_parser = vt:: Parser :: new ( ) ;
91- let mut input_parser = input:: Parser :: new ( ) ;
9290 let mut tui = Tui :: new ( ) ?;
9391
94- let _restore = setup_terminal ( & mut tui, & mut state, & mut vt_parser ) ;
92+ let _restore = setup_terminal ( & mut tui, & mut state) ;
9593
9694 state. menubar_color_bg = tui. indexed ( IndexedColor :: Background ) . oklab_blend ( tui. indexed_alpha (
9795 IndexedColor :: BrightBlue ,
@@ -115,6 +113,11 @@ fn run() -> apperr::Result<()> {
115113
116114 sys:: inject_window_size_into_stdin ( ) ;
117115
116+ // Startup probing may leave partial terminal responses in the probe parser.
117+ // Start application input parsing with an independent parser lifecycle.
118+ let mut vt_parser = vt:: Parser :: new ( ) ;
119+ let mut input_parser = input:: Parser :: new ( ) ;
120+
118121 #[ cfg( feature = "debug-latency" ) ]
119122 let mut last_latency_width = 0 ;
120123
@@ -565,7 +568,7 @@ impl Drop for RestoreModes {
565568 }
566569}
567570
568- fn setup_terminal ( tui : & mut Tui , state : & mut State , vt_parser : & mut vt :: Parser ) -> RestoreModes {
571+ fn setup_terminal ( tui : & mut Tui , state : & mut State ) -> RestoreModes {
569572 sys:: write_stdout ( concat ! (
570573 // 1049: Alternative Screen Buffer
571574 // I put the ASB switch in the beginning, just in case the terminal performs
@@ -597,6 +600,7 @@ fn setup_terminal(tui: &mut Tui, state: &mut State, vt_parser: &mut vt::Parser)
597600 let mut indexed_colors = framebuffer:: DEFAULT_THEME ;
598601 let mut color_responses = 0 ;
599602 let mut ambiguous_width = 1 ;
603+ let mut vt_parser = vt:: Parser :: new ( ) ;
600604
601605 while !done {
602606 let scratch = scratch_arena ( None ) ;
0 commit comments