From 8a29086c1a1948fcfd48228f9271dd0ee90a79db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20CORTIER?= Date: Sat, 5 Jun 2021 12:01:20 -0400 Subject: [PATCH] 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. --- helix-core/src/movement.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/helix-core/src/movement.rs b/helix-core/src/movement.rs index c5e2df4a8..96bbd54b6 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 } }