@@ -8,7 +8,6 @@ pub enum ReadlineResult {
88 Eof ,
99 Interrupt ,
1010 Io ( std:: io:: Error ) ,
11- EncodingError ,
1211 Other ( OtherError ) ,
1312}
1413
@@ -51,11 +50,8 @@ mod basic_readline {
5150 match next_line {
5251 Some ( Ok ( line) ) => ReadlineResult :: Line ( line) ,
5352 None => ReadlineResult :: Eof ,
54- Some ( Err ( e) ) => match e. kind ( ) {
55- io:: ErrorKind :: Interrupted => ReadlineResult :: Interrupt ,
56- io:: ErrorKind :: InvalidData => ReadlineResult :: EncodingError ,
57- _ => ReadlineResult :: Io ( e) ,
58- } ,
53+ Some ( Err ( e) ) if e. kind ( ) == io:: ErrorKind :: Interrupted => ReadlineResult :: Interrupt ,
54+ Some ( Err ( e) ) => ReadlineResult :: Io ( e) ,
5955 }
6056 }
6157 }
@@ -82,7 +78,8 @@ mod rustyline_readline {
8278 . tab_stop ( 8 )
8379 . bracketed_paste ( false ) // multi-line paste
8480 . build ( ) ,
85- ) ;
81+ )
82+ . expect ( "failed to initialize line editor" ) ;
8683 repl. set_helper ( Some ( helper) ) ;
8784 Readline { repl }
8885 }
@@ -109,16 +106,15 @@ mod rustyline_readline {
109106
110107 pub fn readline ( & mut self , prompt : & str ) -> ReadlineResult {
111108 use rustyline:: error:: ReadlineError ;
112- match self . repl . readline ( prompt) {
113- Ok ( line) => ReadlineResult :: Line ( line) ,
114- Err ( ReadlineError :: Interrupted ) => ReadlineResult :: Interrupt ,
115- Err ( ReadlineError :: Eof ) => ReadlineResult :: Eof ,
116- Err ( ReadlineError :: Io ( e) ) => ReadlineResult :: Io ( e) ,
117- #[ cfg( unix) ]
118- Err ( ReadlineError :: Utf8Error ) => ReadlineResult :: EncodingError ,
119- #[ cfg( windows) ]
120- Err ( ReadlineError :: Decode ( _) ) => ReadlineResult :: EncodingError ,
121- Err ( e) => ReadlineResult :: Other ( e. into ( ) ) ,
109+ loop {
110+ break match self . repl . readline ( prompt) {
111+ Ok ( line) => ReadlineResult :: Line ( line) ,
112+ Err ( ReadlineError :: Interrupted ) => ReadlineResult :: Interrupt ,
113+ Err ( ReadlineError :: Eof ) => ReadlineResult :: Eof ,
114+ Err ( ReadlineError :: Io ( e) ) => ReadlineResult :: Io ( e) ,
115+ Err ( ReadlineError :: WindowResized ) => continue ,
116+ Err ( e) => ReadlineResult :: Other ( e. into ( ) ) ,
117+ } ;
122118 }
123119 }
124120 }
0 commit comments