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

Find/Replace overlay: add a search- and replace- history #1990

Merged
merged 1 commit into from
Jul 16, 2024

Conversation

Wittmaxi
Copy link

@Wittmaxi Wittmaxi commented Jun 22, 2024

Adds a history feature for the find and replace bar of the overlay.
The history is displayed using a menu filled with entries from the
HistoryStore.

fixes #1907

grafik
grafik
19

@Wittmaxi
Copy link
Author

@jukzi Can you please review this feature and tell me what you think of it? :)

@jukzi
Copy link
Contributor

jukzi commented Jun 22, 2024

next week

@Wittmaxi
Copy link
Author

@jukzi yes, no rush :)

Copy link
Contributor

github-actions bot commented Jun 22, 2024

Test Results

 1 815 files  +  605   1 815 suites  +605   1h 33m 1s ⏱️ + 30m 48s
 7 677 tests ±    0   7 447 ✅ +    1  228 💤  -   3  2 ❌ +2 
24 192 runs  +8 064  23 440 ✅ +7 825  749 💤 +236  3 ❌ +3 

For more details on these failures, see this check.

Results for commit b6e473d. ± Comparison against base commit be68f2f.

♻️ This comment has been updated with latest results.

@iloveeclipse
Copy link
Member

Instead of the menu (or additionally to it), could we have ctrl+space for the list of proposals, filled with the history?

@Wittmaxi
Copy link
Author

@iloveeclipse I think that could be a good idea! I was also thinking about allowing moving up/down the history using the arrow keys like vscode does. Ctrl+Space fits the "content assist" idiom and is also a very good idea!

@HannesWell
Copy link
Member

Thank you for this. The screenshot already look promising, 🚀

Instead of the menu (or additionally to it), could we have ctrl+space for the list of proposals, filled with the history?

That's also an interesting proposal. But in order to make users aware of it, it should for example be mentioned in the empty-block background text (similar to the screenshot of VS code in #1907).
I'm not 100% sure if a content-assist behavior fits as trigger to show a search history, but maybe that's just based on what I'm used to, but in the end there is no right or wrong.

What also came into my mind when I read Andrey's proposal: The history could automatically drop-down as soon as the text-block gets the focus. Additionally the already typed text could then be used as 'filter' for the history and remove not matching items.
But I'm not sure if this is too much noise if one already knows what to type?

@iloveeclipse
Copy link
Member

order to make users aware of it, it should for example be mentioned in the empty-block background text

Not necessarily, Eclipse has a concept of "light bulb" field decoration if there is something that provides extra functionality.

@Wittmaxi
Copy link
Author

@HannesWell @iloveeclipse @jukzi before coming up with many new features, I would like to understand the problem at hand a little bit better. I never use the search history myself (even in the Dialog) and I couldn't come up with a workflow where the search history could be "really" useful. Can you please tell me a bit about how the search history is really used?

The history could automatically drop-down as soon as the text-block gets the focus.

I never use the search history, for me, this would just be (very) annoying.

@jukzi
Copy link
Contributor

jukzi commented Jun 24, 2024

Can you please tell me a bit about how the search history is really used

example: i search a method in a .java file, but i am too lazy to type each letter of the method name. Therefore i copy paste a Stacktrace line "p.C.method ()" from VisualVm . Since the pasted line contains more then only the method name i have to delete the classname prefix "p.C" and the " ()" suffix within the search dialog. As soon as i have done that i will find a method and all its calls in the active editor. Now i continue with editing, searching other things and so on. Later i want to search the same method again - but still i don't know its name. I used to find its name in the search history. Now i only find it in the copy/paste history from windows but there it still contains prefix and suffix.

@jukzi
Copy link
Contributor

jukzi commented Jun 24, 2024

I have tested it. Optically it is not beautiful but at least it works. Here are my nitpicks:

  • i expect that drop down to be below and aligned to the text field - as it was in the old search dialog:
    image
    old:
    image

  • i expect that active UI components i.e. the drop down to have the highest possible contrast i.e. Black on white - as it was in the old search dialog

  • i expect that up and down keys can be used to scroll through the list - as it was in the old search dialog

  • i expect that i can close the list when i click on on the arrow (that is used to open the list) a second time - as it was in the old search dialog

  • compare to the old search dialog the list wastes much space in the front of the items
    image

In summary i expected that the drop down would be exactly as in the old dialog, because that worked well and i dont know how it could be made better.

@iloveeclipse
Copy link
Member

I never use the search history myself (even in the Dialog) and I couldn't come up with a workflow where the search history could be "really" useful. Can you please tell me a bit about how the search history is really used?

  • Trying to fix ~2000 test fails in not my own code.
  • Searching / replacing different constants / code with other constants / code, also using regex.
  • Mass search/replace doesn't work as code to replace relies on context
  • Gazillion of files opened, same patterns with different variations need to be replaced with other patterns with different variations.
  • Having search and replace field history allows me to search in same file for different occurrences from the history and replace it with different occurrences from the history.
  • Search (and replace) patterns are not trivial text and just typing it would be a constant pain, so history entries for both is essential.

@Wittmaxi
Copy link
Author

@iloveeclipse @jukzi thank you very much for your user-stories! That helps me a lot understanding your concerns for the usability of the history.

It is now possible to navigate through the history using the arrow keys (arrow up/arrow down)
20

I will move on to address @jukzi s concerns.
I have implemented the search history using a menu, but it might be better to implement it as a shell overlaid on the Find/Replace overlay - what do you think?
In particular, I cannot use a Combo (like Find/Replace Dialog does) because it does not fit into the Overlay aesthetically and does also not support all required Operations (for example: it has no concept of a "message" which is the preview text shown when the text bar is empty)

@Wittmaxi Wittmaxi force-pushed the MW_search_history branch 2 times, most recently from 074a7fd to 3b71076 Compare June 24, 2024 09:48
@Wittmaxi
Copy link
Author

@jukzi what do you think of this version?
21

@jukzi
Copy link
Contributor

jukzi commented Jun 24, 2024

it looks good!

  • up/down arrows still not working
  • error: when i press down button again eclipse is send to background!

@jukzi
Copy link
Contributor

jukzi commented Jun 24, 2024

another minor: in the bottom left of the eclipse window the progress shortly says "String xyz not found"
image

  1. The word "String" is something a user does not need to understand. Better: "'xyz' not found"
  2. "xyz NOT FOUND" is a status not a progress, that should not disappear within a tens of a second

--
up/down key work if and only if the replace field is visible.

@jukzi
Copy link
Contributor

jukzi commented Jun 24, 2024

error loged:

org.eclipse.swt.SWTException: Widget is disposed
	at org.eclipse.swt.SWT.error(SWT.java:4922)
	at org.eclipse.swt.SWT.error(SWT.java:4837)
	at org.eclipse.swt.SWT.error(SWT.java:4808)
	at org.eclipse.swt.widgets.Widget.error(Widget.java:500)
	at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java:419)
	at org.eclipse.swt.widgets.Control.isFocusControl(Control.java:1859)
	at org.eclipse.ui.texteditor.FindReplaceOverlay.lambda$0(FindReplaceOverlay.java:195)
	at org.eclipse.swt.events.KeyListener$1.keyPressed(KeyListener.java:66)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:184)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:91)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4300)

@Wittmaxi Wittmaxi force-pushed the MW_search_history branch from 3b71076 to 0b1b622 Compare June 24, 2024 11:20
@Wittmaxi
Copy link
Author

Thank you for the report, I fixed the error here: 0b1b622

Can you please tell me what exactly you do to send eclipse to the background? I could not reproduce that.

Changing the status text is out of scope for this issue. I don't really think it's worth changing (and it is the "old" behavior), but if you think it is, we can create an Issue for it.

@jukzi
Copy link
Contributor

jukzi commented Jun 24, 2024

Can you please tell me what exactly you do to send eclipse to the background? I could not reproduce that.

i am on WIndows. i have multiple programs open. I have replace line closed. I click on down-> history opens. I click on down again .> another program comes in front (feels like closing to the dropdown sends eclipse to background).

@Wittmaxi
Copy link
Author

@jukzi yes, I can reproduce this! Thanks!
I will look into this

@Wittmaxi Wittmaxi force-pushed the MW_search_history branch 2 times, most recently from b7caa6b to d1f08a9 Compare June 24, 2024 14:58
@jukzi
Copy link
Contributor

jukzi commented Jun 25, 2024

now eclispe does not move to background anymore but again drop down can not be closed by second click.

@jukzi
Copy link
Contributor

jukzi commented Jun 25, 2024

  • i can not scroll up/down the drop down with the keys when i use TAB+ENTER to open the drop down (instead the drop down closes)
  • right click on an entry in the drop down opens the context menu of the editor in the background (i was looking if i could remove a search entry from history)

@Wittmaxi
Copy link
Author

Wittmaxi commented Jul 1, 2024

@jukzi I have addressed all your concerns.
Allowing "right click" to remove the menu item is an interesting proposal but out of scope for now. If you want that option added, please create an issue for it :)

@Wittmaxi Wittmaxi force-pushed the MW_search_history branch from 4b6bd53 to 7c21528 Compare July 8, 2024 16:16
@Wittmaxi
Copy link
Author

Wittmaxi commented Jul 8, 2024

@jukzi @HeikoKlare I believe that we should discuss the "unused fields" later and prioritize getting feedback on the search history. I have created this issue for the unused fields #2060 and I have reverted the changes that made them unused.

I have also fixed the unit tests (at least locally) and removed a file which I forgot to remove while merging

Copy link
Contributor

@HeikoKlare HeikoKlare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, the code changes look good and sound. When testing, the UI also looks good and works quite well. I have rather nitpicky comments, but at least one issue (exception) that needs to be addressed:

  • Clicking "down" key when the history is empty results in an exception:
java.lang.ArithmeticException: / by zero
	at org.eclipse.ui.internal.findandreplace.overlay.HistoryTextWrapper.navigateInHistory(HistoryTextWrapper.java:119)
	at org.eclipse.ui.internal.findandreplace.overlay.HistoryTextWrapper.lambda$1(HistoryTextWrapper.java:75)
  • There seems to be an issue with the background color of a separator:
    image

@Wittmaxi Wittmaxi force-pushed the MW_search_history branch 5 times, most recently from c8049b4 to c7042b7 Compare July 15, 2024 10:20
@Wittmaxi
Copy link
Author

I have fixed the divide by zero and the coloring of the separators now works correctly

@Wittmaxi Wittmaxi requested a review from HeikoKlare July 15, 2024 10:23
Copy link
Contributor

@HeikoKlare HeikoKlare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for addressing my concerns! Regarding the code, I only have a minor comment left. For the images, we also need to have a PR with the svg to the platform.images repo.

I have two finding with respect to the UI / layout:

  1. The text boxes are not properly centered (vertically) anymore. They are off to the top.

Before this PR:
image

After this PR:
image

  1. On MacOS, the drop down menu is misplaced (off to the top):
image

private TableColumn column;

public SearchHistoryMenu(Shell parent, HistoryStore history,
HistoryItemSelectedListener menuItemSelectionListener) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be sufficient to use a general Consumer<String> instead of introducing a new (functional) interface here. If not, the listener should at least be declared as a functional interface, so that a lambda instead of an anonymous class can be passed as an argument to this constructor.

});

Point barPosition = textBar.toDisplay(0, 0);
menu.setPosition(barPosition.x, barPosition.y + dropDown.getWidth(), textBar.getSize().x + dropDown.getWidth());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have investigated the MacOS placement issue and found the reason here:
This calculation does not work on MacOS, because the drop down's width returns a default value rather than the actual width. I am not sure whether that implementation is correct/expected, but since the implementation has always been like this, it cannot be changed anyway. Since the bounds contain the correct values, we can adapt the code as follows:

Rectangle dropDownBounds = dropDown.getBounds();
menu.setPosition(barPosition.x, barPosition.y + dropDownBounds.height,
	textBar.getSize().x + dropDownBounds.width);

Without the change, it looks like this:
image

With the change, it looks like this:
image

@HeikoKlare HeikoKlare force-pushed the MW_search_history branch 2 times, most recently from 9ff464d to 02faa47 Compare July 16, 2024 10:56
@HeikoKlare
Copy link
Contributor

@Wittmaxi I have pushed my proposed changed onto your branch: https://github.com/eclipse-platform/eclipse.platform.ui/compare/c7042b7e8f9f3aec27f4d038fa10befb832d8214..9ff464d8c7f049d28d2fd8e12ff026051b2420f1

Maybe you can have a look whether that is fine for you, because I would like to merge this PR soon, so that we finally have that feature available and more easily find potential problems in productive use. If the changes are not okay, just let me know and I will revert them.

@Wittmaxi
Copy link
Author

@HeikoKlare the changes look sound, especially the use of Consumer is much better than a custom object. I can't comment on the mac changes. If they work, that's fine.

thank you :)

@HeikoKlare
Copy link
Contributor

HeikoKlare commented Jul 16, 2024

Thank you for the fast feedback! :-)
With the latest change, the layout on MacOS is as expected (i.e., just like on Windows and Linux). Here are screenshots of the final version from all three OS:

Windows

image

MacOS

image

Linux

image

Add a search history for the Find/Replace overlay, displayed as a
dropdown below the find/replace inputs.

fixes eclipse-platform#1907
@HeikoKlare
Copy link
Contributor

Test failures are unrelated: #294 #1941

Let's merge this and see how the histories behave in productive use. Thank you for contributing this, @Wittmaxi!

@HeikoKlare HeikoKlare merged commit a162c72 into eclipse-platform:master Jul 16, 2024
13 of 16 checks passed
@HeikoKlare
Copy link
Contributor

Can you please share the icon sources in the images repo, @Wittmaxi? It's not urgent, we should just not forget about that. I have created a tracking issue for that: eclipse-platform/eclipse.platform.images#83

And I just saw that the "scrolling hints" you added to the search and replace bar hints were removed in some of the recent commits. What that intended or by accident, so that we should apply that change in a follow-up?

FindReplaceOverlay_searchBar_message=Find (\u2195 for history)
FindReplaceOverlay_replaceBar_message=Replace (\u2195 for history)

@Wittmaxi
Copy link
Author

@HeikoKlare That's not intended and should be re-added. Thanks for the catch :)

I can add an issue for that, I am not at the computer currently

@HeikoKlare
Copy link
Contributor

I can add an issue for that, I am not at the computer currently

I have just created a quick follow-up PR: #2091
No need to have an issue for that.

@HannesWell
Copy link
Member

Thank you for the adding the history to the new overlays. In general this works like charm.

The only thing that made me wonder when using this is that I have to press the UP key to navigate downwards the list of elements in the history. I found it confusing because when I open the full list its also a drop-down menu where the older elements are further down the list.
Also when I open the overlay and want to get the last search back, then I have to press the UP key.
Actually I expected the reverse key-binding: Use DOWN to get to older elements and UP to get newer ones. And also that I have to press DOWN to get my last search back in.

@HeikoKlare
Copy link
Contributor

Thank you for the feedback, @HannesWell! Great to hear that, in general, the functionality works as expected.

I fully agree with your expectation regarding behavior of pressing the up/down keys. I am not sure whether this was ever intended. The only potential reason I found is the behavior of VS code, which moves "downwards" in the history by pressing the "up" button. In this case, I think we should deviate from the VS code behavior because (1) we also have a drop-down menu with an inverse order making the behavior inconsistent and (2) Eclipse users are used to the navigation direction because of the existing find/replace dialog. I have created a PR to invert the navigation direction: #2136

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

Successfully merging this pull request may close these issues.

[Find/Replace Overlay] The search-history cannot be accessed from the Overlay
5 participants