Skip to content

Sort remaining completion candidates in RegexpCompletor#1230

Open
kryzhovnik wants to merge 1 commit into
ruby:masterfrom
kryzhovnik:sort-completion-candidates
Open

Sort remaining completion candidates in RegexpCompletor#1230
kryzhovnik wants to merge 1 commit into
ruby:masterfrom
kryzhovnik:sort-completion-candidates

Conversation

@kryzhovnik

Copy link
Copy Markdown

#379 sorted local variables and string method candidates (fixing #349), but receiver.method completion — the most common case — still returns candidates in method table order, which looks random. Same for symbols, global variables and :: constants. With an ActiveRecord model, u.email_address is listed below all its generated variants:

u.email_address_before_last_save
u.email_address_change_to_be_saved
u.email_address=
...
u.email_address

This sorts candidates in select_message (making the two pre-sorted call sites redundant) and in the symbol/gvar/absolute constant branches.

One detail: candidates starting with _ are sorted last, otherwise completing u. would begin with __id__, __send__, _run_commit_callbacks and similar internals instead of regular methods. Same change for TypeCompletor is proposed in ruby/repl_type_completor#78.

ruby#379 sorted local variables and string method candidates, but
receiver.method completion (the most common case), symbols, global
variables and absolute constants were still returned in method table
order, which looks random in the completion dialog. Sort them too.
Candidates starting with an underscore go last, so that completing
`u.` does not begin with __id__, __send__ and other internals.
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