From 0a4ff5697b4be686782ec3898ee67183e89ac59f Mon Sep 17 00:00:00 2001 From: l0ng-ai <24760907+l0ng-ai@users.noreply.github.com> Date: Mon, 24 Aug 2026 00:46:34 +0800 Subject: [PATCH] test(smart-select): click the contraction that sits between two quotes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `quote_range` refuses outright when the clicked apostrophe is a contraction, and no test ever clicked one that had anything to pair with. The parity count already skips contractions, so on a line carrying no real quote there is nothing to pair with and the refusal looks redundant — every fixture was that line. `echo 'it isn't so' done` is not. Dropping the refusal makes a click inside `isn't` select `'it isn'`: a range that opens at a quote and stops in the middle of a word. The fixture was already there; only the interesting click was missing. --- src/terminal/smart_select.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/terminal/smart_select.rs b/src/terminal/smart_select.rs index 32e42bbc..176833a1 100644 --- a/src/terminal/smart_select.rs +++ b/src/terminal/smart_select.rs @@ -827,6 +827,21 @@ mod tests { let close = chars.iter().rposition(|&c| c == '\'').unwrap(); assert_eq!(quote_range(&chars, open), Some((open, close))); assert_eq!(quote_range(&chars, close), Some((open, close))); + + // And the contraction's own apostrophe pairs with nothing. It is the + // only click that reaches the refusal in `quote_range` itself: the + // parity count already skips contractions, so on a line with no real + // quote on it there is nothing for a contraction to pair with anyway, + // and the check looks redundant. Here there is — clicking inside + // `isn't` would take `'it isn'`, a selection that starts at a quote + // and stops in the middle of a word. + let contraction = chars + .iter() + .position(|&c| c == '\'') + .and_then(|first| chars[first + 1..].iter().position(|&c| c == '\'')) + .map(|i| i + open + 1) + .expect("the fixture has a contraction between its quotes"); + assert_eq!(quote_range(&chars, contraction), None); } #[test]