aboutsummaryrefslogtreecommitdiff
path: root/src/app
diff options
context:
space:
mode:
authorakbash <akbash@herdr.dev>2026-09-10 13:20:03 +0300
committerGitHub <noreply@github.com>2026-09-10 13:20:03 +0300
commit0911056d7eb8fe40bd66acab7e0b7cc71acd4f6a (patch)
tree009fa9d31bfc25597ab0acf48040d23c878f61fc /src/app
parent6fe8f818b91a2565f3546f9dc6b3b18f8a55b065 (diff)
fix: stop token selection at CJK punctuation (#3708)
refs #3706 Co-authored-by: akbash-bot <300245827+akbash-bot@users.noreply.github.com>
Diffstat (limited to 'src/app')
-rw-r--r--src/app/actions.rs36
1 files changed, 35 insertions, 1 deletions
diff --git a/src/app/actions.rs b/src/app/actions.rs
index ca6f6704..d5d13d5a 100644
--- a/src/app/actions.rs
+++ b/src/app/actions.rs
@@ -1485,7 +1485,21 @@ fn is_word_separator(ch: char) -> bool {
ch.is_whitespace()
|| matches!(
ch,
- '|' | '(' | ')' | '[' | ']' | '{' | '}' | ',' | ';' | '!'
+ '|' | '('
+ | ')'
+ | '['
+ | ']'
+ | '{'
+ | '}'
+ | ','
+ | ';'
+ | '!'
+ | '('
+ | ')'
+ | ':'
+ | '、'
+ | '。'
+ | ','
)
}
@@ -2397,6 +2411,11 @@ mod tests {
"/Users/me/Library/Application Support/app/config.json",
),
("echo 你好-world done", "好", "你好-world"),
+ (
+ "註解已補(slice 4 5b5fcc0715):整合原本",
+ "5b5fcc0715",
+ "5b5fcc0715",
+ ),
("先跑 cargo test", "cargo", "cargo"),
(
"export PATH=$HOME/.cargo/bin:$PATH",
@@ -2452,6 +2471,21 @@ mod tests {
}
#[test]
+ fn double_click_word_bounds_treat_cjk_punctuation_as_delimiters() {
+ for delimiter in ['(', ')', ':', '、', '。', ','] {
+ let row = format!("left{delimiter}right");
+ assert_selects(&row, "left", "left");
+ assert_selects(&row, "right", "right");
+ assert_selects_nothing(&row, &delimiter.to_string());
+ assert_eq!(
+ selected_word(&row, col_of(&row, &delimiter.to_string()) + 1),
+ None,
+ "second display cell of {delimiter:?} should not select"
+ );
+ }
+ }
+
+ #[test]
fn double_click_word_bounds_ignore_delimiters() {
for (row, click) in [
(