Fix panic when moving over unicode punctuation

`is_ascii_punctuation` will only work for ASCII punctuations, and when
we have unicode punctuation (or other) we jump into the `unreachable`.
This patch fallback into categorizing everything in this branch as
`Unknown`.

Fixes https://github.com/helix-editor/helix/issues/123

https://github.com/helix-editor/helix/pull/135: add better support for
unicode categories.
pull/157/head
Benoît CORTIER 3 years ago committed by Blaž Hrastnik
parent 16b1cfa3be
commit 8a29086c1a

@ -188,7 +188,9 @@ pub(crate) enum Category {
Eol, Eol,
Word, Word,
Punctuation, Punctuation,
Unknown,
} }
pub(crate) fn categorize(ch: char) -> Category { pub(crate) fn categorize(ch: char) -> Category {
if ch == '\n' { if ch == '\n' {
Category::Eol Category::Eol
@ -199,7 +201,7 @@ pub(crate) fn categorize(ch: char) -> Category {
} else if ch.is_ascii_punctuation() { } else if ch.is_ascii_punctuation() {
Category::Punctuation Category::Punctuation
} else { } else {
unreachable!("unknown '{}' character category", ch) Category::Unknown
} }
} }

Loading…
Cancel
Save