Skip to content

Commit

Permalink
fix panic when max history is zero (fix #4)
Browse files Browse the repository at this point in the history
  • Loading branch information
rhysd committed Oct 4, 2022
1 parent 4e1a999 commit 0ca8573
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/history.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,13 @@ impl History {
}

pub fn push(&mut self, edit: Edit) {
if self.max_items == 0 {
return;
}

if self.edits.len() == self.max_items {
self.edits.pop_front();
self.index -= 1;
self.index = self.index.saturating_sub(1);
}

if self.index < self.edits.len() {
Expand Down

0 comments on commit 0ca8573

Please sign in to comment.