grepWin
grepWin copied to clipboard
Roll back for the Search and Replace
hello. Can I make roll back for a Replace I just made?
I believe can be a simple way to do a roll back in GrepWin. The program must remember the search and replace I made, and inverse them for a new Replace.
For example
SEARCH: This terms
REPLACE: My story
GrepWin will remember this replace, and for roll back will invers and run automatically the inverse replacement:
SEARCH: My story
REPLACE: This terms
GrepWin will remember this replace, and for roll back will invers and run automatically the inverse replacement:
That's naively put: with very simple text files that may work but, although conceptually it seems to make sense, the inverse replacement is not the inverse operation. Some examples which show how the heuristics is fragile:
- Text file which already contains arbitrary occurrences of
My story
- Search and replace
This terms
withMy story
- Rolling back will not obtain the state before the search and replace! (i.e., the initial occurrences of
My story
will also be replaced)
- Search and replace
- Binary files
- These may hold even more undesired results
- An undesired replace clash similar to the explained above easily renders such files as corrupted
A different possibility could be having an Undo button (or similar UI) whenever the Create backup files is checked:
In that case, after a search and replace, the button would become enabled. Basically would just be an automated way of restoring the (backed up) files to their original locations. If no undo files were created (unable to create them due to lack of permissions or such) the button should be disabled; same if the Create backup files is unchecked again and a new replace operation is made.
When looking at this as an improvement, I think the Undo feature should additionally:
- Hold some data (each of the replaced files modification timestamp after replacing)
- Before applying Undo, check if any of the replaced files have changed and prompt the user if so
- "Files were modified since the replace was made: undo may discard latest changes. Proceed?"
- This warning might be somehow related to what most IDE/text editors show when a file is modified outside the environment
What do you think? 🤔
yes, I believe it a a great new function. Must be implemented. The idea will be improved over time. But it is a step forward.
thanks