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
36
src/repl.rs
36
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() {
|
||||
state
|
||||
.terminal
|
||||
.write_line("")
|
||||
.expect(TERMINAL_WRITE_ERROR);
|
||||
let statement = state.statement_buf.iter().collect::<String>();
|
||||
let statement_result = statement.trim();
|
||||
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);
|
||||
state.statement_buf.clear();
|
||||
}
|
||||
let last_line = state.current_line[0..state.current_line.len() - 1].iter().collect::<String>();
|
||||
state.current_line.clear();
|
||||
if !last_line.is_empty()
|
||||
&& ((!state.history.is_empty()
|
||||
&& state.history[state.history.len() - 1] != last_line)
|
||||
|| state.history.is_empty())
|
||||
{
|
||||
state.history.push(last_line);
|
||||
}
|
||||
state.selected_history = 0;
|
||||
prompt(state, args);
|
||||
}
|
||||
}
|
||||
'\n' => {
|
||||
let statement = state.statement_buf.iter().collect::<String>();
|
||||
let statement_result = statement.trim();
|
||||
if statement_result.starts_with('?') {
|
||||
//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
|
||||
.writer
|
||||
.write(state.statement_buf.iter().collect::<String>().as_bytes())
|
||||
.expect(INTERPRETER_WRITE_ERROR);
|
||||
execute(state, args);
|
||||
state.statement_buf.clear();
|
||||
}
|
||||
prompt(state, args);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue