Enhance the Search and Replace capability

Hi,
I’d like to propose the following enhancement to Wappler’s search and replace capability, the one that is invoked clicking on the magnifying glass on the left vertical menu, under Theme management.

  1. Provide a clearly labelled button to Undo the last replacement command

  2. Brownie points: Provide the capability of selecting which previous replacement command to undo.

  3. Allow for the following:

Step 1: Search - Allows to select a pattern to search for. For many of us, a simple string with matching case would be OK for the majority of the cases. For those who know how to use it, allow specifying the string using regex. Allow selecting “match case” and a button to click.

Step 2: Select - Present the results of the search in a manner that allows the developer to

  • Select file(s) as as the target of the replacement command
  • Unselect a selected file(s)
  • Select all the files
  • Unselect all the files

Step 3: Once there is at least one file selected, offer an input for the “replace with” string and a button to fire the “replace” action.

Step 4. Once the “Replace” button is clicked, prompt an “This action will make rrr replacements in fff files. Are you sure?” and show two buttons: Proceed and Cancel.

I think that there would be no further need for the field to enter the File/directory pattern but I’ll leave it up to you to keep it or discard it.

Hope this helps. Many thanks in advance,

Alex

I think the most important suggestion, and probably the easiest to implement, is the “Are you sure?” confirmation. I think anything which could result in serious, unforeseen consequences should display a confirmation dialog. Eg in the case of my favourite text editor, this dialog is displayed:

image

I’m not sure if it’s reasonable to expect such an action to have an ‘undo’ option. Of course, to some extent (and with potentially disastrous consequences), this is available: if you’ve replaced ‘a’ with ‘b’ in 100 files and want to undo this, you can then replace ‘b’ with ‘a’. Good naming conventions might make this sort of ‘undo’ feasible.

The pattern filter is awkward to use. It would be useful if there were built-in options to search within open files, files in a selected folder or all files in the current project for example. I like your Step 2 suggestions - but I wouldn’t put it high on the list of priorities for feature requests.

The undo will be difficult to implement, best is to use git or an other version control on your project to reverse errors you made.

The regexp and match case are already there, the buttons are in the toolbar. Perhaps they should be moved?

Using the search result as a filter for the replace is a good idea, will investigate on what is possible here.

An extra confirmation dialog has been added for the replace all.

Many thanks. Let me know if I can be of any help.