fernandreu / office-ribbonx-editor

An overhauled fork of the original Custom UI Editor for Microsoft Office, built with WPF
MIT License
516 stars 100 forks source link

Find/Replace with option Search Selection fails on subsequent selections #179

Closed Ecalecal closed 2 years ago

Ecalecal commented 2 years ago

Describe the bug Find/Replace fails to target the currently selected code. Instead it seems to get stuck targeting the initially selected code. The program must be restarted to select a new group of code as a work around.

To Reproduce

  1. Select (highlight) multiple lines of code in which to perform the find/replace.
  2. Press CTRL+H (Find/Replace dialog box appears)
  3. Select "Search Selection" option
  4. In the dialog box, enter text to Find and to Replace.
  5. Click Replace All. (Replacement worked as expected.)
  6. Close the dialog box.
  7. Select a different group of code lines, then repeat steps 2 - 5.
  8. (Replacement targets the former selected lines, not the current selection. Select All fails this way as does individual Find or Replace buttons.)

Expected behavior Upon selecting different lines of code and then running the Search/Replace command, it should target that current selection, not the previously selected lines of code.

Additional context Closing the program, then restarting it seems to clear the memory of the previous selected lines of code, where a newly selected group of code works as expected, but then using Find/Replace on a different group of code lines fails as described above.

Win10 Editor v 1.8.0.990

fernandreu commented 2 years ago

Hi @Ecalecal, thanks for reporting this. It should now be fixed in the following build: https://dev.azure.com/fernandreu-public/OfficeRibbonXEditor/_build/results?buildId=1046&view=artifacts&pathAsName=false&type=publishedArtifacts

Basically, the tool was caching the selected text so that any find / replace operation would work off that. This was so that Find Next and similar commands would cycle through the original selection only. This does not work very well with the fact that the find/replace dialog is not modal, i.e. you can keep using the editor (and change your selection) while that dialog is other. Hence, it makes more sense not to cache the selection at all.