Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 360468

Summary: Improve 'Open Resource' dialog filtering sort order
Product: [Eclipse Project] Platform Reporter: Adam Hawthorne <adamh>
Component: IDEAssignee: Platform-UI-Inbox <Platform-UI-Inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P2 CC: akurtakov, bsd, daniel_megert, deepakazad, gautier.desaintmartinlacaze, jan, lbullen, markus.kell.r, siegmaralber
Version: 3.7.1   
Target Milestone: ---   
Hardware: PC   
OS: All   
See Also: https://bugs.eclipse.org/bugs/show_bug.cgi?id=525974
Whiteboard: stalebug
Bug Depends on:    
Bug Blocks: 109670, 387126    
Attachments:
Description Flags
Possible fix none

Description Adam Hawthorne CLA 2011-10-10 13:15:35 EDT
(This probably does not belong in JDT, but I'm not sure what the platform product name is, sorry)

The 'Open Resource' dialog (Ctrl/Cmd+Shift+R) should sort classes with fewer capital letters earlier than those with more.

For instance, I have two files:

ConstantStringMap.java
ConstString.java

Currently, they sort in the above order.  This means I *must* leave the home row and arrow down to get to the ConstString file.  If they sorted in the opposite order, one could type 'CSM' or 'ConstStrM' to eliminate the ConstString item from the list, and hit <enter> directly from the input field.  The camel-caps matching already significantly improves opening resources with long names.  The UI's current behavior of preferring longer names limits its utility for short resources.

-- Configuration Details --
Product: Eclipse SDK 3.7.1.v201109091335 (org.eclipse.sdk.ide)
Installed Features:
 org.eclipse.jdt 3.7.1.r371_v20110810-0800-7z8gFcoFMLfTabvKsR5Qm9rBGEBK
Comment 1 Dani Megert CLA 2011-10-11 02:32:12 EDT
(In reply to comment #0)
> (This probably does not belong in JDT, but I'm not sure what the platform
> product name is, sorry)
> 
np


> The 'Open Resource' dialog (Ctrl/Cmd+Shift+R) should sort classes with fewer
> capital letters earlier than those with more.
> 
> For instance, I have two files:
> 
> ConstantStringMap.java
> ConstString.java

I assume you wanted:
  ConstantStringMap.java
  ConstStringMap.java
otherwise your examples will do what you expect i.e. CSM or ConstStrM will only return 1 result.


> Currently, they sort in the above order.  This means I *must* leave the home
> row and arrow down to get to the ConstString file.  If they sorted in the
> opposite order, one could type 'CSM' or 'ConstStrM' to eliminate the
> ConstString item from the list, and hit <enter> directly from the input field. 
> The camel-caps matching already significantly improves opening resources with
> long names.  The UI's current behavior of preferring longer names limits its
> utility for short resources.
> 

I don't agree that the length of a name (segment) should be used to tweak the sort order. Personally I'd close this as WONTFIX.
Comment 2 Adam Hawthorne CLA 2011-10-11 12:15:07 EDT
(In reply to comment #1)
> 
> I assume you wanted:
>   ConstantStringMap.java
>   ConstStringMap.java
> otherwise your examples will do what you expect i.e. CSM or ConstStrM will
> only return 1 result.

No, not quite.  I want to be able to reach 'ConstString.java' by typing (something like) 'CS' and hitting <enter>  Currently, if I type 'CS', I get:

ConstantStringMap.java
ConstString.java


> 
> I don't agree that the length of a name (segment) should be used to tweak the
> sort order. Personally I'd close this as WONTFIX.

Sorry for being unclear - it's not the _length_ of the name so much as the number of capital letters.  If names with fewer capital letters sorted earlier, typing 'CS' would show:

ConstString.java
ConstStringMap.java

I could select ConstString.java by hitting <enter>, or I could select ConstStringMap.java simplay by adding an 'M', and both are reachable through the camel caps shortcut.
Comment 3 Deepak Azad CLA 2011-10-11 12:42:30 EDT
(In reply to comment #2)
> Sorry for being unclear - it's not the _length_ of the name so much as the
> number of capital letters.  If names with fewer capital letters sorted earlier,
> typing 'CS' would show:
> 
> ConstString.java
> ConstStringMap.java

I just tried this in my dev workspace with 'CS' and 'SWT', and I think the ordering here is random. e.g. with 'CS' as filter I get the following order :)

CancelSearchAction.java
CaseStatement.java
ChangeSignatureProcessor.java
Comment 4 Adam Hawthorne CLA 2011-10-11 12:47:36 EDT
(In reply to comment #3)
> 
> I just tried this in my dev workspace with 'CS' and 'SWT', and I think the
> ordering here is random. e.g. with 'CS' as filter I get the following order :)
> 
> CancelSearchAction.java
> CaseStatement.java
> ChangeSignatureProcessor.java

Hmm... I wonder if it's in order by package name?  Those two classes happen to be in the same package for me.
Comment 5 Deepak Azad CLA 2011-10-11 13:00:34 EDT
(In reply to comment #4)
> Hmm... I wonder if it's in order by package name?  Those two classes happen to
> be in the same package for me.
Nope, file paths are also random.

The only ordering I see in Open Resource dialog (and in Open Type dialog) is that camel case matches appear before exact matches (which I dislike) e.g. with filter as 'SWT'.
Comment 6 Markus Keller CLA 2011-10-11 13:34:17 EDT
(In reply to comment #3)
> I just tried this in my dev workspace with 'CS' and 'SWT', and I think the
> ordering here is random. e.g. with 'CS' as filter I get the following order :)
> 
> CancelSearchAction.java
> CaseStatement.java
> ChangeSignatureProcessor.java

Doesn't look random to me -- it's just alphabetic, ignoring case.

If we touch this for camel case patterns, then we need to make sure that the results don't change their order as the user continues typing more characters.

And we need the same logic in Open Type (such that "SWT" shows SWT before SimpleWildcardTester).
Comment 7 Markus Keller CLA 2011-10-11 13:38:36 EDT
(In reply to comment #5)
> Nope, file paths are also random.

Definitely not.

But there's one caveat with paths, as the help page says: "If the pattern matches many files with the same name, the files that are closer to the currently edited or selected resource are shown on top of the matching items list." This e.g. makes sure that typing "makef" prefers the makefile in the current folder.
Comment 8 Markus Keller CLA 2012-06-18 06:28:09 EDT
This was once fixed in the Open Type dialog, see bug 170885. But the fix was only effective for the old Open Type implementation (TypeInfoViewer).

The relevant part of the comparator needs to be implemented in the FilteredItemsSelectionDialog as well. Note that a 1:1 copy of the code will probably not do it due to the bad code quality of FilteredItemsSelectionDialog (e.g. matchesRawNamePattern(Object) is not used anywhere).
Comment 9 Dani Megert CLA 2012-08-14 03:59:47 EDT
*** Bug 387126 has been marked as a duplicate of this bug. ***
Comment 10 Dani Megert CLA 2012-11-23 05:22:39 EST
*** Bug 394919 has been marked as a duplicate of this bug. ***
Comment 11 Curtis Windatt CLA 2013-04-16 17:20:36 EDT
Created attachment 229780 [details]
Possible fix

Checks if the first character is upper case, then compares the number of initials (upper case letters).  The result with fewer initials goes first.

I reused some internal code from platform UI to collect the initials. For the find resource dialog we can x-friend the usage, but it would be better if someone provides an API for working with camel case.
Comment 12 Dani Megert CLA 2013-04-17 05:34:42 EDT
(In reply to comment #11)
> Created attachment 229780 [details] [diff]
> Possible fix
> 
> Checks if the first character is upper case, then compares the number of
> initials (upper case letters).  The result with fewer initials goes first.
> 
> I reused some internal code from platform UI to collect the initials. For
> the find resource dialog we can x-friend the usage, but it would be better
> if someone provides an API for working with camel case.

Please see comment 6 and comment 8.
Comment 13 Eclipse Genie CLA 2020-07-20 16:00:28 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.