At present, when calculating some ranges, we take the `tuple_windows` to iterate forward, which will cause some problems when the cursor is being front, because `tuple_windows` iteration cannot iterate to the very beginning, so there will be some cases that cannot be calculated, adjust this method, and now it can calculate more perfectly, and the execution speed is about the same Release Notes: - N/A
Unified · Split
| @@ -838,13 +838,16 @@ fn surrounding_markers( · 837 unmodified lines | ||
| 838 | 838 | } |
| 839 | 839 | |
| 840 | 840 | if opening.is_none() { |
| 841 | − for ((ch, range), (before_ch, _)) in movement::chars_before(map, point).tuple_windows() { | |
| 841 | + let mut chars_before = movement::chars_before(map, point).peekable(); | |
| 842 | + while let Some((ch, range)) = chars_before.next() { | |
| 842 | 843 | if ch == '\n' && !search_across_lines { |
| 843 | 844 | break; |
| 844 | 845 | } |
| 845 | 846 | |
| 846 | − if before_ch == '\\' { | |
| 847 | − continue; | |
| 847 | + if let Some((before_ch, _)) = chars_before.peek() { | |
| 848 | + if *before_ch == '\\' { | |
| 849 | + continue; | |
| 850 | + } | |
| 848 | 851 | } |
| 849 | 852 | |
| 850 | 853 | if ch == open_marker { |
| @@ -1209,6 +1212,24 @@ mod test { · 358 unmodified lines | ||
| 1209 | 1212 | let mut cx = NeovimBackedTestContext::new(cx).await; |
| 1210 | 1213 | cx.set_shared_wrap(12).await; |
| 1211 | 1214 | |
| 1215 | + cx.set_shared_state(indoc! { | |
| 1216 | + "\"ˇhello world\"!" | |
| 1217 | + }) | |
| 1218 | + .await; | |
| 1219 | + cx.simulate_shared_keystrokes("v i \"").await; | |
| 1220 | + cx.shared_state().await.assert_eq(indoc! { | |
| 1221 | + "\"«hello worldˇ»\"!" | |
| 1222 | + }); | |
| 1223 | + | |
| 1224 | + cx.set_shared_state(indoc! { | |
| 1225 | + "\"hˇello world\"!" | |
| 1226 | + }) | |
| 1227 | + .await; | |
| 1228 | + cx.simulate_shared_keystrokes("v i \"").await; | |
| 1229 | + cx.shared_state().await.assert_eq(indoc! { | |
| 1230 | + "\"«hello worldˇ»\"!" | |
| 1231 | + }); | |
| 1232 | + | |
| 1212 | 1233 | cx.set_shared_state(indoc! { |
| 1213 | 1234 | "helˇlo \"world\"!" |
| 1214 | 1235 | }) |
| @@ -1,5 +1,15 @@ | ||
| 1 | 1 | {"SetOption":{"value":"wrap"}} |
| 2 | 2 | {"SetOption":{"value":"columns=12"}} |
| 3 | +{"Put":{"state":"\"ˇhello world\"!"}} | |
| 4 | +{"Key":"v"} | |
| 5 | +{"Key":"i"} | |
| 6 | +{"Key":"\""} | |
| 7 | +{"Get":{"state":"\"«hello worldˇ»\"!","mode":"Visual"}} | |
| 8 | +{"Put":{"state":"\"hˇello world\"!"}} | |
| 9 | +{"Key":"v"} | |
| 10 | +{"Key":"i"} | |
| 11 | +{"Key":"\""} | |
| 12 | +{"Get":{"state":"\"«hello worldˇ»\"!","mode":"Visual"}} | |
| 3 | 13 | {"Put":{"state":"helˇlo \"world\"!"}} |
| 4 | 14 | {"Key":"v"} |
| 5 | 15 | {"Key":"i"} |