Skip to content

Commit

Permalink
Remove redundant setting insertion point to 0
Browse files Browse the repository at this point in the history
  • Loading branch information
nixypanda committed Jun 21, 2021
1 parent 2025d88 commit af487f9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 0 additions & 2 deletions src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,6 @@ impl Reedline {

fn clear(&mut self) {
self.line_buffer.clear();
// Note: This should be redundant
self.set_insertion_point(0);
}

fn append_to_history(&mut self) {
Expand Down
9 changes: 9 additions & 0 deletions src/line_buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,15 @@ mod test {
assert!(line_buffer.is_empty())
}

#[test]
fn test_clearing_line_buffer_resets_buffer_and_insertion_point() {
let mut buffer = buffer_with("this is a command");
buffer.clear();
let empty_buffer = LineBuffer::new();

assert_eq!(buffer, empty_buffer)
}

#[test]
fn insert_str_updates_insertion_point_point_correctly() {
let mut line_buffer = LineBuffer::new();
Expand Down

0 comments on commit af487f9

Please sign in to comment.