-
Notifications
You must be signed in to change notification settings - Fork 220
Add Sorting Functionality for Quick Search Results #3012
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
base: master
Are you sure you want to change the base?
Conversation
Hi @mickaelistria |
431fd3f
to
2babf62
Compare
2babf62
to
0685418
Compare
Hi @merks, could you please take a look at this PR when you get a sec? |
577685c
to
573a28b
Compare
hi @iloveeclipse, could you please review this ? |
573a28b
to
2b0e17d
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’m traveling and looking with an iPhone. It’s not clear why some of the fields are arrays. Mostly I see access via [0].
Thanks Ed Merks for checking. I used single-element final arrays here so I could retain and update the values inside |
So why not ordinary non-final fields? Taking off now. |
non-final values can work too, I will update it |
2e2a84c
to
26c7fc8
Compare
26c7fc8
to
159b2a7
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 see (smaller) style issues, but unfortunately too many of them to approve:
- Arrays passed to access first element only to
handleColumnSort()
. Looks ugly, hard to debug. Cant we havesortColumnIndex
andsortDirectionAscending
just as regulat fields? - New code is not properly formatted (no spaces between arguments, in if statements etc). Looks really not nice. E.g.
if(comparator==null)
should beif (comparator == null)
. contentProvider.sortList();
called in the middle of unrelated code inrefreshWidgets()
. Can't it be called afterlist.setItemCount(itemCount);
?items.sort(comparator);
is executed on each call ofgetElements()
. Shouldn't be called once at the place where the sort order is initialized / changed?
Test Results 2 778 files ±0 2 778 suites ±0 1h 32m 50s ⏱️ - 27m 0s For more details on these failures, see this check. Results for commit 159b2a7. ± Comparison against base commit a4840da. |
159b2a7
to
05788ba
Compare
|
05788ba
to
c2bb07a
Compare
c2bb07a
to
fc1b513
Compare
*/ | ||
public void setComparator(Comparator<LineItem> comparator) { | ||
this.comparator = comparator; | ||
items.sort(comparator); |
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.
items.sort(comparator);
is not needed or expected here according to method purpose/javadoc.
The caller side does that already after setting comparator. Please remove this line.
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.
Okay, I have removed it 👍
@Override | ||
public void widgetSelected(SelectionEvent e) { | ||
Comparator<LineItem> lineNumberComparator = Comparator.comparingInt(LineItem::getLineNumber); | ||
handleColumnSort( table, 0, lineNumberComparator); |
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.
Please remove extra in space handleColumnSort( table
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.
done
@Override | ||
public void widgetSelected(SelectionEvent e) { | ||
Comparator<LineItem> textComparator = Comparator.comparing( LineItem::getText); | ||
handleColumnSort( table, 1, textComparator); |
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.
Please remove extra in space handleColumnSort( table
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.
done
column.addSelectionListener(new SelectionAdapter() { | ||
@Override | ||
public void widgetSelected(SelectionEvent e) { | ||
Comparator<LineItem> lineItemComparator = Comparator.comparing( item -> item.getFile().getFullPath().toString()); |
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.
Please remove extra in space Comparator.comparing( item
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.
Done
...eclipse.text.quicksearch/src/org/eclipse/text/quicksearch/internal/ui/QuickSearchDialog.java
Outdated
Show resolved
Hide resolved
This commit adds sorting functionality to the Quick Search results, allowing users to sort entries by Line Number, Text, and Path. Fixes : eclipse-platform#1940
fc1b513
to
62c4d94
Compare
This PR adds sorting functionality to the Quick Search results, enabling users to sort entries by Line Number, Text, or by Path. The update introduces a user interface element (such as a dropdown or clickable column headers) that allows users to choose their preferred sorting method. This improves the usability of the search feature, especially when working with large result sets, by helping users locate relevant entries more quickly.
quick.mp4
Fixes : #1940