Skip to content

Commit

Permalink
Update text_cursor_state.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
rustbasic authored Jun 29, 2024
1 parent 64996d4 commit b5d25bd
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion crates/egui/src/text_selection/text_cursor_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,18 @@ fn next_line_boundary_char_index(it: impl Iterator<Item = char>, mut index: usiz
index
}

/// Determines whether a character is a component of a word.
///
/// Punctuation marks that are commonly used with words are considered word components.
pub fn is_word_char(c: char) -> bool {
c.is_ascii_alphanumeric() || c == '_'
if matches!(
c,
'_' | '-' | ':' | '/' | '.' | '\\' | '@' | '#' | '?' | '='
) {
return true;
}

!c.is_ascii_whitespace() && !c.is_ascii_punctuation()
}

fn is_linebreak(c: char) -> bool {
Expand Down

0 comments on commit b5d25bd

Please sign in to comment.