Skip to content

Commit

Permalink
Clarify doc for TextArea::set_cursor
Browse files Browse the repository at this point in the history
  • Loading branch information
gyscos committed Sep 11, 2023
1 parent f304333 commit 5885af0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cursive-core/src/views/text_area.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,15 @@ impl TextArea {
self.cursor
}

/// Moves the cursor to the given position.
/// Moves the cursor to the given byte position.
///
/// # Panics
///
/// This method panics if `cursor` is not the beginning of a character in
/// This method panics if `cursor` is not the starting byte of a character in
/// the content string.
pub fn set_cursor(&mut self, cursor: usize) {
// TODO: What to do if we fall inside a multi-codepoint grapheme?
// Move back to the start of the grapheme?
self.cursor = cursor;

let focus = self.selected_row();
Expand Down

0 comments on commit 5885af0

Please sign in to comment.