Fix lack of history for ; interpreter submissions
This commit is contained in:
parent
c9c1ab88b9
commit
d7a8e74bd8
1 changed files with 15 additions and 21 deletions
32
src/repl.rs
32
src/repl.rs
|
@ -338,6 +338,10 @@ fn read_loop<F: FnMut(&mut ReplState, &CliArgs)>(args: &CliArgs, state: &mut Rep
|
||||||
}
|
}
|
||||||
';' => {
|
';' => {
|
||||||
if state.in_literal.is_none() {
|
if state.in_literal.is_none() {
|
||||||
|
state
|
||||||
|
.terminal
|
||||||
|
.write_line("")
|
||||||
|
.expect(TERMINAL_WRITE_ERROR);
|
||||||
let statement = state.statement_buf.iter().collect::<String>();
|
let statement = state.statement_buf.iter().collect::<String>();
|
||||||
let statement_result = statement.trim();
|
let statement_result = statement.trim();
|
||||||
if !statement_result.starts_with('?') {
|
if !statement_result.starts_with('?') {
|
||||||
|
@ -348,29 +352,19 @@ fn read_loop<F: FnMut(&mut ReplState, &CliArgs)>(args: &CliArgs, state: &mut Rep
|
||||||
execute(state, args);
|
execute(state, args);
|
||||||
state.statement_buf.clear();
|
state.statement_buf.clear();
|
||||||
}
|
}
|
||||||
}
|
let last_line = state.current_line[0..state.current_line.len() - 1].iter().collect::<String>();
|
||||||
}
|
state.current_line.clear();
|
||||||
'\n' => {
|
if !last_line.is_empty()
|
||||||
let statement = state.statement_buf.iter().collect::<String>();
|
&& ((!state.history.is_empty()
|
||||||
let statement_result = statement.trim();
|
&& state.history[state.history.len() - 1] != last_line)
|
||||||
if statement_result.starts_with('?') {
|
|| state.history.is_empty())
|
||||||
//println!("Got {}", statement_result.unwrap());
|
|
||||||
repl_commands(statement_result, state, args);
|
|
||||||
state.statement_buf.clear();
|
|
||||||
} else if state.bracket_depth == 0
|
|
||||||
&& state.in_literal.is_none()
|
|
||||||
&& state.curly_depth == 0
|
|
||||||
{
|
{
|
||||||
state.statement_buf.push(';');
|
state.history.push(last_line);
|
||||||
state
|
|
||||||
.writer
|
|
||||||
.write(state.statement_buf.iter().collect::<String>().as_bytes())
|
|
||||||
.expect(INTERPRETER_WRITE_ERROR);
|
|
||||||
execute(state, args);
|
|
||||||
state.statement_buf.clear();
|
|
||||||
}
|
}
|
||||||
|
state.selected_history = 0;
|
||||||
prompt(state, args);
|
prompt(state, args);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue