summaryrefslogtreecommitdiff
path: root/test/normal/insert-replace
diff options
context:
space:
mode:
authorJohannes Altmanninger <aclopte@gmail.com>2025-05-10 21:23:31 +0200
committerMaxime Coste <mawww@kakoune.org>2025-05-11 09:57:17 +1000
commita89747c458b7e316ba78fc0a52fad36f827dd63f (patch)
tree9ab09d530699343c53a33f0dee8191660989cc4d /test/normal/insert-replace
parent3241f1b63025ebad4f8706594acf265f0e5e9c4a (diff)
Fix <a-?> crash when first selection wraps
The <?> and <a-?> commands drop selections where the search wrapped. If a selection is dropped this way, we adjust the new main index. If the very first selection is dropped this way, *and* it happens to be the main index, "--main_index" overflows and chaos ensues. Fix this by saturating main index at zero. This seems more intuitive than wrapping around ("% new_sels.size()"). This issue only happens to <a-?>, not <?>. When <?> wraps when starting from the first selection, it necessarily also wraps after all other selections. (Based on this insight, I started drafting an optimization to skip searches whose results would be discarded anyway because they will definitely wrap. Not sure if it's worth it, since it applies only to the rare edge case of <?>/<a-?> with multiple selections.) Fixes #5314
Diffstat (limited to 'test/normal/insert-replace')
0 files changed, 0 insertions, 0 deletions