Skip to content

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

SougandhS
Copy link

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

@SougandhS
Copy link
Author

Hi @mickaelistria
Could you please check this PR when you have some time..

@SougandhS SougandhS force-pushed the quickSearchSorting branch 3 times, most recently from 431fd3f to 2babf62 Compare June 10, 2025 05:30
@SougandhS SougandhS force-pushed the quickSearchSorting branch from 2babf62 to 0685418 Compare June 13, 2025 03:13
@SougandhS
Copy link
Author

Hi @merks, could you please take a look at this PR when you get a sec?

@SougandhS SougandhS force-pushed the quickSearchSorting branch 2 times, most recently from 577685c to 573a28b Compare June 20, 2025 05:48
@SougandhS
Copy link
Author

hi @iloveeclipse, could you please review this ?

@SougandhS SougandhS force-pushed the quickSearchSorting branch from 573a28b to 2b0e17d Compare June 24, 2025 12:00
Copy link
Contributor

@merks merks left a 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].

@SougandhS
Copy link
Author

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 TableColumn.addSelectionListener 's new SelectionAdapter() {...}.(). class.

@merks
Copy link
Contributor

merks commented Jun 24, 2025

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 TableColumn.addSelectionListener 's new SelectionAdapter() {...}.(). class.

So why not ordinary non-final fields? Taking off now.

@SougandhS
Copy link
Author

So why not ordinary non-final fields? Taking off now.

non-final values can work too, I will update it

@SougandhS SougandhS force-pushed the quickSearchSorting branch 2 times, most recently from 2e2a84c to 26c7fc8 Compare June 26, 2025 10:33
@SougandhS SougandhS requested a review from merks June 29, 2025 15:18
@SougandhS SougandhS force-pushed the quickSearchSorting branch from 26c7fc8 to 159b2a7 Compare June 29, 2025 15:18
Copy link
Member

@iloveeclipse iloveeclipse left a 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:

  1. Arrays passed to access first element only to handleColumnSort(). Looks ugly, hard to debug. Cant we have sortColumnIndex and sortDirectionAscending just as regulat fields?
  2. New code is not properly formatted (no spaces between arguments, in if statements etc). Looks really not nice. E.g. if(comparator==null) should be if (comparator == null).
  3. contentProvider.sortList(); called in the middle of unrelated code in refreshWidgets(). Can't it be called after list.setItemCount(itemCount); ?
  4. items.sort(comparator); is executed on each call of getElements(). Shouldn't be called once at the place where the sort order is initialized / changed?

Copy link
Contributor

Test Results

 2 778 files  ±0   2 778 suites  ±0   1h 32m 50s ⏱️ - 27m 0s
 7 930 tests ±0   7 701 ✅  - 1  228 💤 ±0  1 ❌ +1 
23 345 runs  ±0  22 598 ✅  - 1  746 💤 ±0  1 ❌ +1 

For more details on these failures, see this check.

Results for commit 159b2a7. ± Comparison against base commit a4840da.

@SougandhS SougandhS force-pushed the quickSearchSorting branch from 159b2a7 to 05788ba Compare July 1, 2025 03:00
@SougandhS
Copy link
Author

I see (smaller) style issues, but unfortunately too many of them to approve:

  1. Done, refactored accordingly
  2. Done
  3. Done, removed from refreshWidgets() -> didn't required when 4. was done
  4. Done, moved to block where comparator is set

@SougandhS SougandhS force-pushed the quickSearchSorting branch from 05788ba to c2bb07a Compare July 1, 2025 03:00
@SougandhS SougandhS force-pushed the quickSearchSorting branch from c2bb07a to fc1b513 Compare July 8, 2025 08:49
*/
public void setComparator(Comparator<LineItem> comparator) {
this.comparator = comparator;
items.sort(comparator);
Copy link
Member

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.

Copy link
Author

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);
Copy link
Member

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

Copy link
Author

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);
Copy link
Member

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

Copy link
Author

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());
Copy link
Member

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

Copy link
Author

Choose a reason for hiding this comment

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

Done

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
@SougandhS SougandhS force-pushed the quickSearchSorting branch from fc1b513 to 62c4d94 Compare July 10, 2025 00:38
@SougandhS SougandhS requested a review from iloveeclipse July 10, 2025 00:39
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.

Quick Search: Allow ordering of search results by Path
3 participants