summaryrefslogtreecommitdiff
path: root/helix-core/src/movement.rs
diff options
context:
space:
mode:
authorBenoît CORTIER2021-06-05 16:01:20 +0000
committerBlaž Hrastnik2021-06-07 00:12:01 +0000
commit8a29086c1a1948fcfd48228f9271dd0ee90a79db (patch)
tree8e643713beae636d738d051fbe933713e51d4682 /helix-core/src/movement.rs
parent16b1cfa3be2665e78bea6c876d3ced96dbfeb44f (diff)
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.
Diffstat (limited to 'helix-core/src/movement.rs')
-rw-r--r--helix-core/src/movement.rs4
1 files changed, 3 insertions, 1 deletions
diff --git a/helix-core/src/movement.rs b/helix-core/src/movement.rs
index c5e2df4a..96bbd54b 100644
--- a/helix-core/src/movement.rs
+++ b/helix-core/src/movement.rs
@@ -188,7 +188,9 @@ pub(crate) enum Category {
Eol,
Word,
Punctuation,
+ Unknown,
}
+
pub(crate) fn categorize(ch: char) -> Category {
if ch == '\n' {
Category::Eol
@@ -199,7 +201,7 @@ pub(crate) fn categorize(ch: char) -> Category {
} else if ch.is_ascii_punctuation() {
Category::Punctuation
} else {
- unreachable!("unknown '{}' character category", ch)
+ Category::Unknown
}
}