File tree Expand file tree Collapse file tree 1 file changed +19
-3
lines changed
crates/q_cli/src/cli/chat Expand file tree Collapse file tree 1 file changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -473,10 +473,26 @@ where
473473 style:: SetForegroundColor ( Color :: Reset ) ,
474474 ) ?;
475475 }
476- let user_input = match self . input_source . read_line ( Some ( "> " ) ) ? {
477- Some ( line) => line,
478- None => return Ok ( ChatState :: Exit ) ,
476+
477+ // Require two consecutive sigint's to exit.
478+ let mut ctrl_c = false ;
479+ let user_input = loop {
480+ match ( self . input_source . read_line ( Some ( "> " ) ) ?, ctrl_c) {
481+ ( Some ( line) , _) => break line,
482+ ( None , false ) => {
483+ execute ! (
484+ self . output,
485+ style:: Print ( format!(
486+ "\n (To exit, press Ctrl+C or Ctrl+D again or type {})\n \n " ,
487+ "/quit" . green( )
488+ ) )
489+ ) ?;
490+ ctrl_c = true ;
491+ } ,
492+ ( None , true ) => return Ok ( ChatState :: Exit ) ,
493+ }
479494 } ;
495+
480496 Ok ( ChatState :: HandleInput {
481497 input : user_input,
482498 tool_uses : Some ( tool_uses) ,
You can’t perform that action at this time.
0 commit comments