From abde9f2194c42ad7030fbbc5fc16fcff06a08754 Mon Sep 17 00:00:00 2001 From: Eddy Ernesto del Valle Pino Date: Sun, 30 Jul 2017 12:30:56 +0200 Subject: [PATCH] Put private members or internal methods in the bottom in completion. --- super_elixir/autocomplete.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/super_elixir/autocomplete.py b/super_elixir/autocomplete.py index ec31b92..b6d685f 100644 --- a/super_elixir/autocomplete.py +++ b/super_elixir/autocomplete.py @@ -64,10 +64,11 @@ def on_query_completions(self, view, prefix, locations): return completions def _sort_by_frequency_in_view(self, buffer, completions): - for completion in completions: - completion['count'] = buffer.count(completion['name']) - - completions.sort(key=lambda c: (-c['count'], c['name'])) + completions.sort(key=lambda c: ( + -buffer.count(c['name']), + len(c['name']) - len(c['name'].strip('_')), + c['name'], + )) return completions def on_hover(self, view, point, hover_zone):