stefankueng / grepWin

A powerful and fast search tool using regular expressions
https://tools.stefankueng.com/grepWin.html
GNU General Public License v3.0
1.74k stars 180 forks source link

[Feature request] Preview replaced text before replacing #387

Closed Destroy666x closed 1 year ago

Destroy666x commented 1 year ago

Whenever I do a complex regex with this tool, I'm scared that I might be missing some edge case. It would be nice if there was a dropdown for Replace button that would show all the effects of replaces that will be executed in all files, as mistakes can happen even if you carefully test on regex101.

I saw that a similar feature request got rejected because there's Test regex: https://github.com/stefankueng/grepWin/issues/56#issuecomment-436777680 This is not the same at all because you can't copy all the matched lines there, at least I don't see an easy way for it. It could of course reuse that window, why not, and automatically insert all the matched lines there as inputs.

stefankueng commented 1 year ago

You can also just check the box "create backup files" and do the replacement. Then if it's not what you expected you can restore the backups.

Destroy666x commented 1 year ago

It's a good option for security indeed. Not great for quickly checking all the changes though, when replacing in a lot of files, hundreds or thousands.

stefankueng commented 1 year ago

So, think about this: ... button that would show **all** the effects of replaces that will be executed in **all** files ... and then ... when replacing in a lot of files, **hundreds or thousands**.

now imagine e.g. ten thousand files with a hundred replacements in each. No only would that use up a lot of memory, but how would you show that to the user? And be honest: would you be able to spot your edge cases in so many replacements?

So I don't really see any real benefits in such a feature.

Destroy666x commented 1 year ago

now imagine e.g. ten thousand files with a hundred replacements in each. No only would that use up a lot of memory,

Could set some limits to avoid memory issues.

but how would you show that to the user?

Bunch of possibilities. Pagination is one.

And be honest: would you be able to spot your edge cases in so many replacements?

In my case of ~300 files with 1 change in most and max few in some - definitely, it would be very helpful, otherwise I wouldn't request this. With thousands or more I agree it'd be less since i'ts unlikely many people would look through so many changes.