reset ReadlineStream from read_query_line (#1317, #1285)

This commit is contained in:
Mark Thom
2022-03-05 10:38:16 -07:00
parent d7a3ed2d4a
commit 66c209f9e4
2 changed files with 8 additions and 1 deletions

View File

@@ -1053,7 +1053,8 @@ impl Stream {
file_stream.stream.get_mut().file.seek(SeekFrom::Start(0)).unwrap(); file_stream.stream.get_mut().file.seek(SeekFrom::Start(0)).unwrap();
return true; return true;
} }
Stream::Readline(_) => { Stream::Readline(ref mut readline_stream) => {
readline_stream.reset();
return true; return true;
} }
_ => { _ => {

View File

@@ -111,6 +111,12 @@ impl ReadlineStream {
} }
} }
#[inline]
pub fn reset(&mut self) {
self.pending_input.get_mut().clear();
self.pending_input.set_position(0);
}
fn call_readline(&mut self) -> std::io::Result<usize> { fn call_readline(&mut self) -> std::io::Result<usize> {
match self.rl.readline(get_prompt()) { match self.rl.readline(get_prompt()) {
Ok(text) => { Ok(text) => {