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

Roll back for the Search and Replace #259

Open
me-suzy opened this issue May 28, 2021 · 3 comments
Open

Roll back for the Search and Replace #259

me-suzy opened this issue May 28, 2021 · 3 comments

Comments

@me-suzy
Copy link

me-suzy commented May 28, 2021

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

@HelderMagalhaes
Copy link

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 with My 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)
  • Binary files
    • These may hold even more undesired results
    • An undesired replace clash similar to the explained above easily renders such files as corrupted

@HelderMagalhaes
Copy link

A different possibility could be having an Undo button (or similar UI) whenever the Create backup files is checked:
image

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? 🤔

@me-suzy
Copy link
Author

me-suzy commented Jun 3, 2021

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

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

No branches or pull requests

2 participants