Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limit amount of matches during replacement #2151

Closed
wants to merge 1 commit into from

Conversation

ghost
Copy link

@ghost ghost commented Feb 24, 2022

The buffer passed to the replace function can be bigger than the original match
and cause extra matches to occur during replacement. This adds an extra replace
function that doesn't allow matches beyond the original range to get replaced.

I've added replace_with_captures_in_range to do this, but I'm not sure if this should be fixed within
replace_with_captures_at itself (as that one isn't always used with a range).

Fixes #2095

Skip matches beyond the original range when
replacing a buffer with captures.
@ghost
Copy link
Author

ghost commented May 14, 2022

Resolved by #2209

@ghost ghost closed this May 14, 2022
@BurntSushi
Copy link
Owner

Ah I missed this PR! Thanks. I did end up taking a slight different approach by writing the new function as a new internal helper routine instead of making it a new public API in grep-matcher. Probably grep-matcher should evolve its *_at APIs to accept ranges instead of just the starting location. But that's a battle for another day.

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

--multiline with --replace causes duplicate output
1 participant