File tree Expand file tree Collapse file tree 1 file changed +26
-16
lines changed
crates/q_cli/src/cli/chat Expand file tree Collapse file tree 1 file changed +26
-16
lines changed Original file line number Diff line number Diff line change @@ -35,22 +35,32 @@ impl InputSource {
3535
3636 pub fn read_line ( & mut self , prompt : Option < & str > ) -> Result < Option < String > , ReadlineError > {
3737 match & mut self . 0 {
38- inner:: Inner :: Readline ( rl) => loop {
39- let line = rl. readline ( prompt. unwrap_or ( "" ) ) ;
40- match line {
41- Ok ( line) => {
42- if line. trim ( ) . is_empty ( ) {
43- continue ;
44- }
45- let _ = rl. add_history_entry ( line. as_str ( ) ) ;
46- return Ok ( Some ( line) ) ;
47- } ,
48- Err ( ReadlineError :: Interrupted | ReadlineError :: Eof ) => {
49- return Ok ( None ) ;
50- } ,
51- Err ( err) => {
52- return Err ( err) ;
53- } ,
38+ inner:: Inner :: Readline ( rl) => {
39+ let mut prompt = prompt. unwrap_or_default ( ) ;
40+ let mut line = String :: new ( ) ;
41+ loop {
42+ let curr_line = rl. readline ( prompt) ;
43+ match curr_line {
44+ Ok ( l) => {
45+ if l. trim ( ) . is_empty ( ) {
46+ continue ;
47+ } else if l. ends_with ( "\\ " ) {
48+ line. push_str ( & l) ;
49+ prompt = ">> " ;
50+ continue ;
51+ } else {
52+ line. push_str ( & l) ;
53+ let _ = rl. add_history_entry ( line. as_str ( ) ) ;
54+ return Ok ( Some ( line) ) ;
55+ }
56+ } ,
57+ Err ( ReadlineError :: Interrupted | ReadlineError :: Eof ) => {
58+ return Ok ( None ) ;
59+ } ,
60+ Err ( err) => {
61+ return Err ( err) ;
62+ } ,
63+ }
5464 }
5565 } ,
5666 inner:: Inner :: Mock { index, lines } => {
You can’t perform that action at this time.
0 commit comments