@@ -358,6 +358,7 @@ impl ChatHinter {
358358 let triple_backtick_count = line. matches ( "```" ) . count ( ) ;
359359 if triple_backtick_count % 2 == 1 {
360360 // We have an odd number of ```, meaning we're in multiline mode
361+ // Show status hint (right arrow key is overridden to not complete this)
361362 return Some ( "in multiline mode, waiting for closing backticks ```" . to_string ( ) ) ;
362363 }
363364 }
@@ -559,6 +560,34 @@ impl rustyline::ConditionalEventHandler for PasteImageHandler {
559560 }
560561}
561562
563+ /// Handler for right arrow key that prevents completing the multiline status hint
564+ struct RightArrowHandler ;
565+
566+ impl rustyline:: ConditionalEventHandler for RightArrowHandler {
567+ fn handle (
568+ & self ,
569+ _evt : & rustyline:: Event ,
570+ _n : rustyline:: RepeatCount ,
571+ _positive : bool ,
572+ ctx : & rustyline:: EventContext < ' _ > ,
573+ ) -> Option < Cmd > {
574+ let line = ctx. line ( ) ;
575+
576+ // Check if we're in multiline mode with unclosed backticks
577+ if line. contains ( "```" ) {
578+ let triple_backtick_count = line. matches ( "```" ) . count ( ) ;
579+ if triple_backtick_count % 2 == 1 {
580+ // We're in multiline mode - don't complete the hint
581+ // Just move the cursor forward instead
582+ return Some ( Cmd :: Move ( rustyline:: Movement :: ForwardChar ( 1 ) ) ) ;
583+ }
584+ }
585+
586+ // Normal case - complete the hint
587+ Some ( Cmd :: CompleteHint )
588+ }
589+ }
590+
562591pub fn rl (
563592 os : & Os ,
564593 sender : PromptQuerySender ,
@@ -652,6 +681,12 @@ pub fn rl(
652681 EventHandler :: Conditional ( Box :: new ( PasteImageHandler :: new ( paste_state) ) ) ,
653682 ) ;
654683
684+ // Override right arrow key to prevent completing multiline status hints
685+ rl. bind_sequence (
686+ KeyEvent ( KeyCode :: Right , Modifiers :: empty ( ) ) ,
687+ EventHandler :: Conditional ( Box :: new ( RightArrowHandler ) ) ,
688+ ) ;
689+
655690 Ok ( rl)
656691}
657692
0 commit comments