daddel80 / notepadpp-multireplace

MultiReplace is a plugin for Notepad++ enabling multi-string replacement, allowing list saving and loading. It provides CSV syntax highlighting and enabling precise column targeting. Additionally, it introduces conditional and computational operations within the replacement string.
GNU General Public License v2.0
20 stars 7 forks source link

Nil value breaks following capture variables #52

Closed tonibony closed 1 month ago

tonibony commented 1 month ago

This issue happens when searching with RE and replacing in "Use variables" mode. When a match is found, if one of the capture variables becomes nil, all subsequent capture variables also become nil, even if their corresponding subexpressions have matched.

Find what: (this) *(is)? *(a match) Replace with: set("CAP1 = <" .. (CAP1 or "?") .. ">, CAP2 = <" .. (CAP2 or "?") .. ">, CAP3 = <" .. (CAP3 or "?") .. ">") Use Variables: YES Search Mode: Regular expression

Sample text:

this is a match
but is this a match

And here is the result:

CAP1 = <this>, CAP2 = <is>, CAP3 = <a match>
but is CAP1 = <this>, CAP2 = <?>, CAP3 = <?>
daddel80 commented 1 month ago

Hi Tonibony,

Thanks for reporting the issue. I have already located the part in the code and will provide you with an update soon.

tonibony commented 1 month ago

Take your time, I won't need a fix anytime soon.

daddel80 commented 1 month ago

Hi tonibony,

Thanks for catching that bug, even if you don't need the fix asap. Appreciate your help! Here’s the new BUILD 472. If you want, you can test the correction and let me know or simply close this issue.

I'll include this fix in the next Notepad++ release.

daddel80 commented 1 month ago

fix will be available in MultiReplace Release 3.1.2.18