]> Repositorios git - scryer-prolog.git/commitdiff
reset current input in ReadQueryTerm
authorMark Thom <[email protected]>
Mon, 11 May 2020 21:29:28 +0000 (15:29 -0600)
committerMark Thom <[email protected]>
Mon, 11 May 2020 21:29:28 +0000 (15:29 -0600)
src/prolog/machine/streams.rs
src/prolog/machine/system_calls.rs
src/prolog/read.rs

index 1eefe58172aec9bad275cd19c8bf50936bc8e643..84abb488d16806cc926eb0f00bcc4b2ea2db9f81 100644 (file)
@@ -540,7 +540,10 @@ impl Stream {
 
     // returns true on success.
     #[inline]
+    pub(super)
     fn reset(&mut self) -> bool {
+        self.stream_inst.0.borrow_mut().0 = false;
+
         match self.stream_inst.0.borrow_mut().1 {
             StreamInstance::Bytes(ref mut cursor) => {
                 cursor.set_position(0);
@@ -550,8 +553,7 @@ impl Stream {
                 file.seek(SeekFrom::Start(0)).unwrap();
                 true
             }
-            StreamInstance::ReadlineStream(ref mut stream) => {
-                *stream = ReadlineStream::new(String::new());
+            StreamInstance::ReadlineStream(_) => {
                 true
             }
             _ => {
index 025997169c0dbb20074a12964ea7368c73083141..86f32fcbb37368f638b44f18d0d7d72adc07298e 100644 (file)
@@ -4235,6 +4235,8 @@ impl MachineState {
                 }
             }
             &SystemClauseType::ReadQueryTerm => {
+                current_input_stream.reset();
+
                 readline::set_prompt(true);
                 let result = self.read_term(current_input_stream.clone(), indices);
                 readline::set_prompt(false);
index 4751759ef40dce68975437d8ac28c51c9a1d0c50..61065b80297ea405533afd3fcde680468f22450a 100644 (file)
@@ -42,11 +42,6 @@ pub mod readline {
     }
 
     impl ReadlineStream {
-        pub fn new(pending_input: String) -> Self {
-            let rl = Editor::<()>::new();
-            ReadlineStream { rl, pending_input: Cursor::new(pending_input) }
-        }
-
         pub fn input_stream(pending_input: String) -> Stream {
             let mut rl = Editor::<()>::new();
             rl.bind_sequence(KeyPress::Tab, Cmd::Insert(1, "\t".to_string()));