summaryrefslogtreecommitdiff
path: root/test/normal/search-reverse-extending-multiple-selections/cmd
AgeCommit message (Collapse)Author
2025-05-11Fix <a-?> crash when first selection wrapsJohannes Altmanninger
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