From 24b8942713114f26dc6f4c2e244b4aae2f287df8 Mon Sep 17 00:00:00 2001 From: David Halter Date: Wed, 21 Nov 2012 17:31:01 +0100 Subject: [PATCH] Script.complete: sorting with underlines as last arguments --- jedi/api.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/jedi/api.py b/jedi/api.py index e892d59d..4ff19e6e 100644 --- a/jedi/api.py +++ b/jedi/api.py @@ -86,7 +86,7 @@ class Script(object): """ An auto completer for python files. - :return: list of Completion objects. + :return: list of Completion objects, sorted by name and __ comes last. :rtype: list """ path = self.module.get_path_until_cursor() @@ -146,7 +146,8 @@ class Script(object): c = [api_classes.Completion( c, needs_dot, len(like), s) for c, s in completions] - return c + return sorted(c, key=lambda x: (x.word.startswith('__'), + x.word.lower())) def _prepare_goto(self, goto_path, is_like_search=False): """ Base for complete, goto and get_definition. Basically it returns