mirror of
https://github.com/lune-org/lune.git
synced 2025-05-04 10:43:57 +01:00
feat: store history & allow for history traversing
This commit is contained in:
parent
bd594e6f07
commit
09050be633
1 changed files with 10 additions and 2 deletions
|
@ -7,7 +7,9 @@ use std::{
|
||||||
|
|
||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result};
|
||||||
use clap::{CommandFactory, Parser};
|
use clap::{CommandFactory, Parser};
|
||||||
use rustyline::{error::ReadlineError, DefaultEditor};
|
use rustyline::{
|
||||||
|
error::ReadlineError, Cmd, DefaultEditor, EventHandler, KeyCode, KeyEvent, Modifiers,
|
||||||
|
};
|
||||||
|
|
||||||
use lune::Lune;
|
use lune::Lune;
|
||||||
use tokio::{
|
use tokio::{
|
||||||
|
@ -198,6 +200,11 @@ impl Cli {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// repl.bind_sequence(
|
||||||
|
// KeyEvent(KeyCode::Enter, Modifiers::SHIFT),
|
||||||
|
// EventHandler::Simple(Cmd::AcceptOrInsertLine { accept_in_the_middle: true }),
|
||||||
|
// );
|
||||||
|
|
||||||
let mut interrupt_counter = 0u32;
|
let mut interrupt_counter = 0u32;
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
|
@ -205,7 +212,8 @@ impl Cli {
|
||||||
|
|
||||||
match repl.readline("> ") {
|
match repl.readline("> ") {
|
||||||
Ok(code) => {
|
Ok(code) => {
|
||||||
source_code = code;
|
source_code = code.clone();
|
||||||
|
repl.add_history_entry(code.as_str())?;
|
||||||
|
|
||||||
// If source code eval was requested, we reset the counter
|
// If source code eval was requested, we reset the counter
|
||||||
interrupt_counter = 0;
|
interrupt_counter = 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue