Search results unchanged after a change.
-
When I use the “Find All in Current Document” button, i get a list of all the occurances of the find string in the file. After applying a change all occurances, to something slightly different, The search results still show the original list. it would be nice if after the change all, the search resutls window updated to show the new results.
i am guessing this could potentially slow thigs down on a very large file, but perhaps it could be a option on the Replace popup dialog to refresh the last find all? The last find all in the Search results window, not the last find in the Repalce popup Dialog!.
Without having to re-do the search is there another way to do this?
-
@Alan-Wynne
VSCode is doing it so there should be a 'way to do this". VSCode is doing it also for find-in-files, which is way cooler.But it will require a complete rewrite of the feature so I would not hold my breath.
Notepad++ approach is very simple: the user requests a search, Notepad++ runs the “query”, The query collets the results into internal static storage from which they are presented. At this stage the query is mostly forgotten.I guess that someone at VSCode took it upon himself (as a challenge) to design the search window as an active query that updates the results for various events: internal and external. It also seems to update the results selectively based on the event rather than run the entire query to be fast. Your question has woken my curiosity so I tested VSCode a bit. The results are updated when you edit the file. The results are also updated when you edit the file externally. The results are removed when you delete a file but the results are not updated when you bring the file back (e.g. from git). I guess the search window listens for file events but not for directory events.
So again, cool but difficult to implement.
-
@gstavi Could the Replace function after it has completed, not do the following:
Check if a search results window is open, then if a flag is set to refresh the search results, do so. This should not necessarily require a re-write of the search, it is just a re-do of the search after a replace has hapened. All it would require is the parameters of the search to be stored somewhere in the search results data…
I think the flag to reset the search results is necessary, becuase when dealing with very large files, the search can take very long, and may not be desireable in every instance.
-
@Alan-Wynne said in Search results unchanged after a change.:
Check if a search results window is open, then if a flag is set to refresh the search results, do so. This should not necessarily require a re-write of the search, it is just a re-do of the search after a replace has hapened. All it would require is the parameters of the search to be stored somewhere in the search results data…
Every keystroke could change the results, you would need to run the query for every newly typed symbol and for every delete. Since this will be way too slow, you will need a multithreaded implementation that will rerun the query in the background. This is a complete redesign.
-
@gstavi Do you realy need that kind of responsiveness? All I am asking for is that after doing a replace all in the Replace Popup dialog box, is for the search results window to reflect the changes the replace all did. I agree that keeping the search results window updated for every key stoke would be a bit much!
-
Also, the Search results window in Notepad++ could contain hundreds (or more) of previous-run search data…are all of them to be updated?
A “better” idea might be to have a right-click option “Rerun this search”. This could either add a result at the top of the tree with new data, or replace the entry right-clicked upon in place.
-
@Alan-Wynne said in Search results unchanged after a change.:
@gstavi Do you realy need that kind of responsiveness? All I am asking for is that after doing a replace all in the Replace Popup dialog box, is for the search results window to reflect the changes the replace all did. I agree that keeping the search results window updated for every key stoke would be a bit much!
That sounds really weird to me.
You search for xxx from the find dialog.
You replace all xxx to yyy from the search dialog.
Now you want Notepad++ to do what?
Show all the lines with yyy?
Do you want to show also lines that had yyy from before the replace or only lines that participated in the replace? Because I don’t think that Notepad++ will know to do the latter.
Is there a functional need for that or do you just not trust Notepad++ to replace correctly?Yes. I believe that should be easy to implement, but I doubt many users would like such option to clutter the UI.
-
@gstavi said in Search results unchanged after a change.:
You replace all xxx to yyy from the search dialog.
Now you want Notepad++ to do what?
Show all the lines with yyy?I think (can’t check right now) that when Visual Studio’s editor does a replace-in-files, it populates its find-output window with all of the replacements made – this sounds similar to what OP here is describing?
-
Here are some links that might be of interest for the discussion in this thread:
-
@Alan-Kilborn said in Search results unchanged after a change.:
I think (can’t check right now) that when Visual Studio’s editor does a replace-in-files, it populates its find-output window with all of the replacements made – this sounds similar to what OP here is describing?
Reply
Don’t use Visual Studio much, but as I said Visual Studio Code search & replace is extremely advanced and dynamic.
When you type a search string it is updating the search results in real-time, highlighting the search string.
When you type a replace string it dynamically overstrike the original “search” string in the results, highlighted in RED and present after it the “replace” string in green. All of this before actually commiting to the search and replace.Extremely cool. Impressive work of engineering. However, the benefit over Notepad++ primitive search and replace is limited.
Admittedly, search and replace is error prone so the ability to see the results BEFORE helps boosting your confidence. However, that is not what was asked by @Alan-WynneSo my claims are:
- Doing anything similar to VSCode is a complete rewrite.
- Doing simple post search has questionable value. Doing it automatically could annoy lots of users.
An undo feature for search and replace in files would be nice.