Closed monsanto closed 9 years ago
Thank you for taking the time to come up with a good example. @syohex has provided a patch, which I will merge as soon.
The root of the error is that optional groups (\(...\)?
) result in (match-data)
with nil entries, which was not handled correctly. I never use optional groups, which explains why I never encountered this.
For my information: why do you use optional groups like those? You only need groups if you need to reference them in the replace string. I can't come up with a good use case.
Excellent, thanks for the speedy resolution.
@benma Three reasons:
*
, +
, or ?
on a group of characters. One can use the \(?:
construct but it is unwieldy for interactive use.\(...\)?
is a character shorter than \(...\|\)
\(...\)x?\(...\)
, you want to go to \(...\)\(...\)
, and your current cursor position is before x
. You might instinctively want to type delete twice, but after the first keypress everything breaks.Good points!
The PR is merged now. Please let me know if it works for you.
To reproduce: In any buffer, M-x
vr/replace
, paste\(\\\)?\(\)
. You will get the following error:Any subsequent interaction with visual-regexp will raise
Wrong type argument: overlap, nil
.EDIT: just to be clear, this error comes up for me fairly often on real world queries, the one above is just a minimal example. I've been trying to reproduce this one for a while now