Skip to content

Commit

Permalink
Merge 2563766 into 24744c9
Browse files Browse the repository at this point in the history
  • Loading branch information
pythonbrad committed Sep 15, 2023
2 parents 24744c9 + 2563766 commit ccae31a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions clafrica-lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,11 @@ pub mod text_buffer {
pub fn clear(&mut self) {
self.buffer.clear();
}

/// Verify if the cursor is empty
pub fn is_empty(&self) -> bool {
return self.buffer.iter().filter(|c| c.key != '\0').count() == 0;
}
}
}

Expand Down Expand Up @@ -316,6 +321,7 @@ mod tests {
);
undo!(cursor 4);
assert_eq!(cursor.to_sequence(), vec!['\0', '\0']);
assert!(cursor.is_empty());
undo!(cursor 1);
assert_eq!(cursor.to_sequence(), vec![]);

Expand Down

0 comments on commit ccae31a

Please sign in to comment.