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

console.lua: preserve the order of items with equal score #15709

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

guidocella
Copy link
Contributor

console.lua: preserve the order of items with equal score

table.sort() is unstable, meaning that it randomly reorders items with the same score, so currently fuzzy_find() checks if the line is empty to not change the original order of the unsorted items. But actually filled lines have the same problem: e.g. searching foo with filenames like foo_{1..99}, they are returned in random order.

To fix this sort by score only when 2 items have different score, else sort by the original position.

console.lua: sort completions

With the previous commit, this sorts completions with the same score alphabetically.

table.sort() is unstable, meaning that it randomly reorders items with
the same score, so currently fuzzy_find() checks if the line is empty to
not change the original order of the unsorted items. But actually filled
lines have the same problem: e.g. searching foo with filenames like
foo_{1..99}, they are returned in random order.

To fix this sort by score only when 2 items have different score, else
sort by the original position.
With the previous commit, this sorts completions with the same score
alphabetically.
Copy link

Download the artifacts for this pull request:

Windows
macOS

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.

1 participant