updated max_hist default to 10,000 and added an option to remove the cap by setting it to -1

This commit is contained in:
2026-03-05 09:34:02 -05:00
parent 30ada66cab
commit 1efaf0e516
3 changed files with 11 additions and 10 deletions

View File

@@ -217,12 +217,13 @@ impl History {
format!("{home}/.shed_history")
}));
let mut entries = read_hist_file(&path)?;
// Enforce max_hist limit on loaded entries
if entries.len() > max_hist {
entries = entries.split_off(entries.len() - max_hist);
// Enforce max_hist limit on loaded entries (negative = unlimited)
if max_hist >= 0 && entries.len() > max_hist as usize {
entries = entries.split_off(entries.len() - max_hist as usize);
}
let search_mask = dedupe_entries(&entries);
let cursor = search_mask.len();
let max_size = if max_hist < 0 { None } else { Some(max_hist as u32) };
Ok(Self {
path,
entries,
@@ -233,7 +234,7 @@ impl History {
cursor,
//search_direction: Direction::Backward,
ignore_dups,
max_size: Some(max_hist as u32),
max_size,
})
}