vim: Update AnyQuotes and AnyBrackets to behave like mini.ai plugin #24845
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This PR improves the existing mini.ai‐like text-object logic for both “AnyQuotes” (quotes) and “AnyBrackets” (brackets) by adding a multi‐line fallback. The first pass searches only the current line for a best match (cover or next); if none are found, we do a multi‐line pass. This preserves mini.ai's usual “line priority” while ensuring we can detect pairs that start on one line and end on another.
What Changed
gather_line_brackets(map, caret.row())
to find bracket pairs((), [], {}, <>)
on the caret’s line.gather_brackets_multiline(map)
to single‐pass scan the defined region by number of lines, collecting bracket pairs that might span multiple lines.pick_best_range
) to choose the best.gather_line_quotes(map, caret.row())
.gather_quotes_multiline(map)
, building a big string for the whole buffer and using naive regex for "...", '...', and...
.ciq
), we skip bounding quotes or brackets if the range is at least 2 characters wide.caq
), we return the entire range.finalize
” helpersfinalize_bracket_range
andfinalize_quote_range
handle the “inner” skip‐chars vs. “outer” logic.Why This Matters
Example Use Cases
Tests
Limitations / Future Enhancements
Important Notes
References:
Thank you for reviewing these changes!
Release Notes: