-
Notifications
You must be signed in to change notification settings - Fork 193
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
[Modern Find/Replace] Refactor FindReplaceDialog #1132
[Modern Find/Replace] Refactor FindReplaceDialog #1132
Conversation
I expect that there is still a lot to change - especially since this is a rather intrusive change. |
bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplacer.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should avoid adding new API nor take risk of changing existing ones if there is not clear other consumer showing it's needed. I would rather delay the merge of those refactorings to when we can see how they contribute to providing value.
To rephrase it, I think it would be better to start by introducing the new UI (the find/replace bar) alternative to FindReplaceDialog and then reorganize the existing code so that it can serve both alternatives.
...les/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceStatus.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplacer.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplacer.java
Outdated
Show resolved
Hide resolved
...les/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceStatus.java
Outdated
Show resolved
Hide resolved
@mickaelistria Thank you for looking into this! 😊 I don't intend on adding anything to the API, everything should be under-the-hood. Are you referring to the package-visibility of the classes only? I will update this PR to be easier to diff (removing unneeded changes, etc...) and move on to branch from this branch, implementing the UI-Changes there |
a918c59
to
109b417
Compare
Test Results 903 files ±0 903 suites ±0 1h 5m 10s ⏱️ - 7m 4s For more details on these failures, see this check. Results for commit ccc3203. ± Comparison against base commit 2ff9d30. ♻️ This comment has been updated with latest results. |
@mickaelistria have your concerns be addressed? Looks like it to me... |
Thanks for the heads-up. I'll try to review it later today. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's great to separate the business functionality from the UI. The business code should be kept internal (i.e., be package private or in an internal package) for now, as proposed in https://github.com/eclipse-platform/eclipse.platform.ui/pull/1132/files#r1329665672. Then the current errors/warnings with respect to version bumps and warnings about non-API return type will become obsolete.
Currently, the internal status object of the FindReplacer
can be modified by consumers. This seems to be a bug. My other comments rather concern code design/style.
bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplacer.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplacer.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplacer.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplacer.java
Outdated
Show resolved
Hide resolved
...les/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceStatus.java
Outdated
Show resolved
Hide resolved
...les/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceStatus.java
Outdated
Show resolved
Hide resolved
...les/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceDialog.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplacer.java
Outdated
Show resolved
Hide resolved
...les/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceDialog.java
Outdated
Show resolved
Hide resolved
109b417
to
4c44e33
Compare
...lipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindAndReplaceMessageStatus.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindAndReplace.java
Outdated
Show resolved
Hide resolved
@mickaelistria anything open here from your side? |
As mentioned earlier on the initial issue, I find pointless to merge such refactorings if there is not a change demonstrating it creates value for it (ie another consumer). Having a 2nd consumer included in the same change allows to validate that the refactoring serves a goal well; without it I won't spend more time in the review. |
4c44e33
to
5d6f9fc
Compare
I see the point of @mickaelistria, so some additional comments on this PR:
|
@Wittmaxi please look into the build errors, these need definitely be adressed. |
Thank you for your interest @vogella, @mickaelistria, @HeikoKlare I personally still see the need for change in this PR:
In order to get feedback in as quickly as possible (=> Eclipse Con!), I am currently pushing to get the Find/Replace-Dialog in a state that is good enough for us to get valuable and helpful feedback as well as some excitement in the community of users (no hard commitment, but I'm hoping to have it out by next wednesday). Once that is ready, I will get back to the nitty-gritties of this issue. I have created a local pr of the new FindReplace Overlay, that makes reviewing easier. If anybody already wants to look into what is happening, I'm very happy to hearing first thoughts! The build-errors come from a problem in version numbers. Since I want to merge this PR together with the other branch, I'm not sure how I best proceed in increasing the version numbers. Any ideas? |
Just send another PR with the version increase, I can merge it and afterwards you rebase this change onto master. |
527ed76
to
455ac2d
Compare
This push addressed all warnings present in the files of this PR and updates the JavaDocs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like the separation of UI and business code, but the business code still looks rather unstructured to me. In particular, I would propose to extract an interface that captures the "publicly" available and accordingly documented functionality of some find and replace implementation. I see this interface (that is currently implicitly represented via the public methods of the FindReplaceLogic
implementation) as one of the most important outcomes of this PR. There are already some public methods in FindReplaceLogic
that should actually not be there (like isEditable()
).
...lipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindAndReplaceMessageStatus.java
Outdated
Show resolved
Hide resolved
...lipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindAndReplaceMessageStatus.java
Outdated
Show resolved
Hide resolved
...lipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindAndReplaceMessageStatus.java
Outdated
Show resolved
Hide resolved
...lipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindAndReplaceMessageStatus.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceLogic.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceLogic.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceLogic.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceLogic.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceLogic.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceLogic.java
Outdated
Show resolved
Hide resolved
@Wittmaxi please have a look at the test errors. |
555a45e
to
fd00115
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have tested with the recent changes again and only found one remaining regression:
When search wraps, the old implementation produced a beep because no result was found before wrapping. The new implementation does, however, not produce a beep in that case.
...pse.ui.workbench.texteditor/src/org/eclipse/ui/internal/findandreplace/FindReplaceLogic.java
Outdated
Show resolved
Hide resolved
...pse.ui.workbench.texteditor/src/org/eclipse/ui/internal/findandreplace/FindReplaceLogic.java
Outdated
Show resolved
Hide resolved
...ch.texteditor.tests/src/org/eclipse/ui/workbench/texteditor/tests/FindReplaceDialogTest.java
Outdated
Show resolved
Hide resolved
fd00115
to
c5665cc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was not able to find any regressions in behavior anymore 👍 only one in message colors (see comment). I only see two minor things left as documented in the comments.
...les/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceDialog.java
Outdated
Show resolved
Hide resolved
...les/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceDialog.java
Outdated
Show resolved
Hide resolved
c5665cc
to
28ccc58
Compare
} | ||
} | ||
tryToBeep(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now you removed the parameter evaluation.
4f7b6ae
to
71a55e6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for addressing all my previous comments have all been addressed. Unfortunately I find further behavior changes everytime I test the PR. Now I see these differences to the old behavior remaining:
- Invalid regex expressions are printed as info, not as error (i.e., not in red font).
- Beep is only performed for find operation, not for other operations.
...les/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceDialog.java
Outdated
Show resolved
Hide resolved
if (statusMessage.getMessageCode() != null && beep) { | ||
tryToBeep(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beep also needs to be performed in these cases:
- "Select All" without a match
- "Replace All" without a match
- Any operation with "regular expression" activated and the input is not a valid regular expression (e.g., "(" without ")")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my current setup, I could not reproduce beep on
- Select all with 0 matches (not regex)
- Replace all with 0 matches (not regex)
I could reproduce the beep on faulty RegEx.
I have nevertheless implemented all of your suggestions: although I believe they introduce a difference between current behaviour and new behaviour, they still make sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another bug I found: "replace all" and "select all" don't work in backwards mode |
71a55e6
to
116106a
Compare
I could resolve the regressions I found - I also implemented @HeikoKlare 's suggestions even though I cannot reproduce the behaviour mentioned in the comment on my local machine. |
The FindReplaceDialog's business-logic is now handled in the FindReplacer. The FindReplacer communicates using a FindReplaceStatus object which is polled by FindReplaceDialog as needed and allows for displaying correct messages in the Interface. This Refactoring is required so that the business-logic can be reused in the new FindReplace overlay, as proposed in issue eclipse-platform#1090
116106a
to
1d6bc22
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for verifying and addressing my findings. I cannot reproduce the behavior for "Select All" and "Replace All" either. I am not sure which configuration I used there, maybe it was only related to an invalid regex.
Still I agree with you that the changed behavior makes sense. I think after disentangling the distributed behavior for message color and beeps, we now have a better understanding when they are supposed to apply. My understanding is as follows:
- There are two "error cases" for a find/replace operation:
- "Invalid input": any of the input values is invalid. This currently applies to a read-only target and to an invalid regex pattern
- "Unapplicable": Nothing matching the search pattern is found in the target, so the operation cannot be applied (showing a find result, applying a replace etc.)
- Invalid inputs are currently represented by a red-colored message, whereas unapplicability is confirmed with a beep.
The proposed implementation seems to almost properly reflect this (at least as properly as the existing ones does). Still, I propose to improve the code design in terms of replacing switch logic in the beep handling to a proper representation of this behavior in the search operation status objects (like done with the isError()
method for invalid input). Doing that, we can also properly reflect this behavior at all, because, e.g. "Select All" executed on read-only targets currently gives invalid results. But since this PR now seems to be almost fine from a functional perspective, let's keep it is as it is and not mix it up with further optimizations that can be conducted independently.
Still, there are now some things broken (again).
- Shift+Enter with backwards search enabled does not work (which is why a test fails)
- When changing the input in incremental search mode, the result always moves to the next result, even if the current one is fitting.
In addition, the added isError
parameter for the FindStatus
constructor is unnecessary due to above considerations: It can be extracted from the messageCode
field, as error state depends on whether the target is read only. One nitpicky thing I also noticed is that there are still things named "FindReplacer" rather than "FindReplaceLogic".
To be able to merge this soon, I contribute a fix for these things together with a regression test for the inverse search behavior in a separate commit (1d6bc22) on this PR rather than doing further iterations.
9fc3a0c
to
bf1fbd7
Compare
* Makes incremental search consider the current selection if still matching instead of moving to the next match * Makes Shift+Enter invert search direction even if backwards search is enabled and adds regression test for that behavior * Avoids that search for whole words stays enabled when the checkbox becomes disabled and adds a regression test for that behavior * Improves naming of IStatus#isError() to IStatus#isInputValid() * Renames identifiers containing "FindReplacer" to "FindReplaceLogic"
bf1fbd7
to
ccc3203
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have now intensively validated the behavior and only found a minor regression related to checkbox disablements not being considered properly: in case the "whole word" checkbox becomes disabled because more than a single word is interted into the input field (or because regex search is enabled), the "whole word" option stays enabled if the checkbox was ticked before it became disabled. I fixed this and provided an according regression test as an amendment in ccc3203. Everything else worked for me.
From my side, this one is ready to merge. I think we have enough time left in the current release cycle to find potential regressions in case we have missed anything during our validations. Since this PR is a prerequisite for the modernized find/replace UI (#1192), not merging it would complicate further development of that contribution. And there are also other issues regarding the find functionality (like #1029) which make more sense to be addressed in refactored code rather than fixing the current code and then rebasing the fix onto the refactored one.
@vogella Anything from your side that speaks against merging this?
No concerns from my side, the improved search UI is the top development for the Eclipse IDE I'm really waiting for as a user so I'm really happy that you @HeikoKlare did this detailed review and check of the development from @Wittmaxi @Wittmaxi please continue with the UI improvement, IMHO this improvement is huge for our user base. |
@vogella thank you for merging the PR and for the kind words :) |
All the thanks goes to you @Wittmaxi and @HeikoKlare for doing the actual work. I just act as an impatient user who really, really wants this new search experience. :-o |
The FindReplaceDialog's business-logic is now handled in the FindReplacer.
The FindReplacer communicates using a FindReplaceStatus object which is polled by FindReplaceDialog as needed and allows for displaying correct messages in the Interface.
This Refactoring is required so that the business-logic can be reused in the new FindReplace overlay, as proposed in issue #1090