|
|
|
@ -1,5 +1,9 @@
|
|
|
|
|
use helix_loader::command_histfile;
|
|
|
|
|
use std::{fs::OpenOptions, io::Write};
|
|
|
|
|
use std::{
|
|
|
|
|
fs::{File, OpenOptions},
|
|
|
|
|
io::{self, BufRead, BufReader, Lines, Write},
|
|
|
|
|
path::PathBuf,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
pub fn push_history(register: char, line: &str) {
|
|
|
|
|
let filepath = match register {
|
|
|
|
@ -17,3 +21,15 @@ pub fn push_history(register: char, line: &str) {
|
|
|
|
|
// TODO: do something about this unwrap
|
|
|
|
|
writeln!(file, "{}", line).unwrap();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn read_histfile(filepath: PathBuf) -> Lines<BufReader<File>> {
|
|
|
|
|
// TODO: do something about this unwrap
|
|
|
|
|
BufReader::new(File::open(filepath).unwrap()).lines()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn read_command_history() -> Vec<String> {
|
|
|
|
|
read_histfile(command_histfile())
|
|
|
|
|
.collect::<io::Result<Vec<String>>>()
|
|
|
|
|
// TODO: do something about this unwrap
|
|
|
|
|
.unwrap()
|
|
|
|
|
}
|
|
|
|
|