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

Sort order for file quickopen should prefer shorter paths #17443

Closed
spion opened this issue Dec 17, 2016 · 1 comment
Closed

Sort order for file quickopen should prefer shorter paths #17443

spion opened this issue Dec 17, 2016 · 1 comment
Assignees
Labels
search Search widget and operation issues
Milestone

Comments

@spion
Copy link

spion commented Dec 17, 2016

I love VSCode, but the sort order for quickopen doesn't work all that well sometimes...

For example, shorter files within longer paths should not trump over shorter paths with a longer filename, especially if the search string includes a path separator

  • VSCode Version: 1.8
  • OS Version: OS X

Steps to Reproduce:

  1. Create a file named config/test.js
  2. Create a subfolder named config/test
  3. Create the files config/test/t1.js and config/test/t2.js
  4. Use quick open and type co/te

Expected first result: config/test.js
Actual first result: confing/test/t1.js. config/test.js comes only after t2

@spion
Copy link
Author

spion commented Dec 17, 2016

Minimal patch that demonstrates an improved behaviour:

diff --git a/src/vs/base/common/comparers.ts b/src/vs/base/common/comparers.ts
index a90bc8f..f0993ef 100644
--- a/src/vs/base/common/comparers.ts
+++ b/src/vs/base/common/comparers.ts
@@ -126,7 +126,7 @@ export function compareByScore<T>(elementA: T, elementB: T, accessor: IScorableR
        }

        // At this place, the scores are identical so we check for string lengths and favor shorter ones
-       if (labelA.length !== labelB.length) {
+       if (!/[\/]/.test(lookFor) && labelA.length !== labelB.length) {
                return labelA.length < labelB.length ? -1 : 1;
        }

but it looks like this is a generic label-and-path scoring algorithm, so I'm not sure if it will affect other things negatively?

@chrmarti chrmarti added feature-request Request for new features or functionality search Search widget and operation issues labels Dec 19, 2016
@bpasero bpasero added this to the October 2017 milestone Oct 3, 2017
@bpasero bpasero assigned bpasero and unassigned chrmarti Oct 3, 2017
@bpasero bpasero removed the feature-request Request for new features or functionality label Oct 3, 2017
@bpasero bpasero closed this as completed Oct 3, 2017
bpasero added a commit that referenced this issue Oct 3, 2017
@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 17, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
search Search widget and operation issues
Projects
None yet
Development

No branches or pull requests

3 participants