Bug 528977 - [content assist] Content Assist suggestions order is expected to be optimized
Summary: [content assist] Content Assist suggestions order is expected to be optimized
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 4.7.1a   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-Text-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-12-19 22:53 EST by Fuwei Chin CLA
Modified: 2018-02-11 15:21 EST (History)
3 users (show)

See Also:


Attachments
content assist suggestions order (11.26 KB, image/png)
2017-12-19 22:53 EST, Fuwei Chin CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Fuwei Chin CLA 2017-12-19 22:53:42 EST
Created attachment 271970 [details]
content assist suggestions order

Steps to Reduce:
In Java Editor
1) Input 'FileU'
2) Press Alt+/ to call Content Assist

Actual Result:
The first suggestion Content Assist suggestion list is 'FilenameUtils' and the second is 'FileUtils'.

Expected Result:
The first suggestion is 'FileUtils' and the second is 'FilenameUtils'.
Comment 1 Stephan Herrmann CLA 2017-12-20 07:53:02 EST
Much thought has already gone into sorting of proposals. Judging just from one example it's not clear how the algorithm should be changed. To make your request actionable it would be great if you could define a rule that would create the order you expect.
Based on that we'd have to check if it conflicts with any existing rule.
Comment 2 Dani Megert CLA 2017-12-20 10:22:48 EST
Same problem in Open Type (see bug 527957).
Comment 3 Dani Megert CLA 2017-12-20 10:25:22 EST
(In reply to Stephan Herrmann from comment #1)
> Much thought has already gone into sorting of proposals. Judging just from
> one example it's not clear how the algorithm should be changed.

For me it is clear:

FileUtils is a closer match for FileU than FilenameUtil
Comment 4 Stephan Herrmann CLA 2017-12-20 10:53:18 EST
(In reply to Dani Megert from comment #2)
> Same problem in Open Type (see bug 527957).

I thought the "perfect match" case was already fixed. Seeing (part of) it still unresolved I agree that the goal should be clear.
Comment 5 Patrik Suzzi CLA 2018-02-11 15:21:55 EST
Once excluded the perfect match, we could sort the remaining entries by numeric rank = number of consecutive characters of the searchString found in the entry.

example:

searchString = "FileU"

ranking(searchString, "FileUtils") -> 5
ranking(searchString, "FilenameUtils") -> 4 

Computationally, the complexity is < N*M, where N : number of remaining entries, M : number of characters in the search string.

a possible implementation:

    static int rank(String search, String entry) {
        int result = 0;
        for (int i = 0; i < search.length() && i < entry.length(); i++) {
            if (search.charAt(i) != entry.charAt(i)) {
                break;
            }
            result++;
        }
        return result;
    }