mirror of
https://github.com/teo3300/rust-mal.git
synced 2026-01-12 09:15:32 +01:00
Fixing history
- Histroy was loaded from correct but saved in wrong file - Somehow multiline string only works while loading files (not bad) - Fixing error on not-ended string: unrecoverable Signed-off-by: teo3300 <matteo.rogora@live.it>
This commit is contained in:
@ -69,11 +69,12 @@ use rustyline::DefaultEditor;
|
||||
pub fn interactive(env: Env) {
|
||||
const HISTORY: &str = ".mal-history";
|
||||
let home = get_home_path(&env).unwrap();
|
||||
let history = home + "/" + HISTORY;
|
||||
|
||||
// Using "Editor" instead of the standard I/O because I hate myself but not this much
|
||||
// TODO: remove unwrap and switch to a better error handling
|
||||
let mut rl = DefaultEditor::new().unwrap();
|
||||
if rl.load_history(&(home + "/" + HISTORY)).is_err() {
|
||||
if rl.load_history(&history).is_err() {
|
||||
eprintln!("; Failed to load history");
|
||||
}
|
||||
|
||||
@ -96,7 +97,7 @@ pub fn interactive(env: Env) {
|
||||
Ok(line) => {
|
||||
// TODO: should handle this in a different way
|
||||
rl.add_history_entry(&line).unwrap();
|
||||
rl.save_history(HISTORY).unwrap();
|
||||
rl.save_history(&history).unwrap();
|
||||
|
||||
parser.push(&line);
|
||||
|
||||
|
||||
@ -102,7 +102,7 @@ impl Reader {
|
||||
if tk.len() > 2 && tk.ends_with('\"') {
|
||||
Ok(Str(unescape_str(tk)))
|
||||
} else {
|
||||
Err(MalErr::recoverable(
|
||||
Err(MalErr::unrecoverable(
|
||||
"End of line reached without closing string",
|
||||
))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user