consume remaining

This commit is contained in:
TcMits
2025-09-09 16:27:31 +07:00
parent 8a6667a829
commit 048e72abf5
2 changed files with 7 additions and 3 deletions

View File

@@ -484,7 +484,7 @@ impl Limbo {
}
// consume will consume `input_buff`
pub fn consume(&mut self) -> anyhow::Result<()> {
pub fn consume(&mut self, flush: bool) -> anyhow::Result<()> {
if self.input_buff.trim().is_empty() {
return Ok(());
}
@@ -503,6 +503,10 @@ impl Limbo {
self.run_query(value);
self.reset_input();
}
(false, false) if flush => {
self.run_query(value);
self.reset_input();
}
(false, false) => {
self.set_multiline_prompt();
}

View File

@@ -64,7 +64,7 @@ fn main() -> anyhow::Result<()> {
loop {
match app.readline() {
Ok(_) => match app.consume() {
Ok(_) => match app.consume(false) {
Ok(_) => {}
Err(e) => {
eprintln!("{e}");
@@ -83,7 +83,7 @@ fn main() -> anyhow::Result<()> {
}
Err(ReadlineError::Eof) => {
// consume remaining input before exit
match app.consume() {
match app.consume(true) {
Ok(_) => {}
Err(e) => {
eprintln!("{e}");