Improve history handling with regards to position and duplicates
This commit is contained in:
parent
aa164087fa
commit
fae004f76c
@ -3,7 +3,7 @@ use std::collections::VecDeque;
|
||||
pub struct History {
|
||||
pub entries: VecDeque<String>,
|
||||
pub max_size: usize,
|
||||
current_position: Option<usize>,
|
||||
pub current_position: Option<usize>,
|
||||
}
|
||||
impl Default for History {
|
||||
fn default() -> Self {
|
||||
|
@ -359,7 +359,11 @@ impl LineState {
|
||||
self.clear_and_render(term)?;
|
||||
|
||||
// Add to history...
|
||||
if self.history.entries.front() != Some(&line) {
|
||||
self.history.entries.push_front(line.clone());
|
||||
self.history.entries.truncate(self.history.max_size);
|
||||
}
|
||||
self.history.current_position = None;
|
||||
|
||||
// Return line
|
||||
return Ok(Some(ReadlineEvent::Line(line)));
|
||||
|
Loading…
Reference in New Issue
Block a user