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 autocomplete by showing lowercase first #526

Merged
merged 5 commits into from
Oct 23, 2020

Conversation

iboss-ptk
Copy link
Contributor

Resolve part of #302:

  • lowercase first, then uppercase

@fonsp
Copy link
Owner

fonsp commented Oct 2, 2020

If it sorts in reverse, does it now give z before a?

@iboss-ptk
Copy link
Contributor Author

@fonsp It is. Should we go like

lowercase
uppercase
the rest
sorted alphabetically for each bucket instead?

@fonsp
Copy link
Owner

fonsp commented Oct 5, 2020

Yep! Just a style comment: you can use a stable sort algorithm like MergeSort, and sort by a function that just assigns categories:

heuristic(s::String) = if islowercase(firstchar(s))
	1
elseif isuppercase(firstchar(s)
	2
else
	3
end

sorted_completions = sort(completions, by=heuristic, algortihm=MergeSort)

(pseudocode)

@iboss-ptk
Copy link
Contributor Author

@fonsp cool! I will look into that :D

@fonsp fonsp merged commit 4daf433 into fonsp:master Oct 23, 2020
@fonsp fonsp added the autocomplete <TAB> label Mar 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants