Skip to content

Commit

Permalink
Fix ordering of autocompletion.
Browse files Browse the repository at this point in the history
  • Loading branch information
edelvalle committed Nov 25, 2017
1 parent b36ddb2 commit fb53012
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions super_elixir/autocomplete.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def on_query_completions(self, view, prefix, locations):
return

location = locations[0]
on_character = view.substr(location)
on_character = view.substr(location)
prev_char = view.substr(location - 1)

param_auto_completion = (
Expand Down Expand Up @@ -55,7 +55,7 @@ def on_query_completions(self, view, prefix, locations):

if self._is_function(s):
arity = s.get('arity')
args = s.get('args', '').split()
args = s.get('args', '').split(',')

if not args and arity:
args = ['_'] * arity
Expand All @@ -73,11 +73,20 @@ def on_query_completions(self, view, prefix, locations):

completions.append(c)

completions.sort(key=lambda c: (
len(c['name']) - len(c['name'].strip('_')), # less underscores wins
c['name'], # alphabetically
))

completions = [
['{show}\t{hint}'.format(**c), c['completion']]
for c in completions
]
return completions
return (
completions,
sublime.INHIBIT_WORD_COMPLETIONS |
sublime.INHIBIT_EXPLICIT_COMPLETIONS
)

def _is_function(self, suggestion):
return (
Expand Down

0 comments on commit fb53012

Please sign in to comment.