From ccdf7eddf461db1d78b34391d92e0f3c234d645e Mon Sep 17 00:00:00 2001 From: Yoni Weill Date: Sat, 5 Dec 2020 21:11:32 +0200 Subject: [PATCH] add Completion.get_completion_prefix_length fixes #1687 --- jedi/api/classes.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/jedi/api/classes.py b/jedi/api/classes.py index a8d9fb19..42aac726 100644 --- a/jedi/api/classes.py +++ b/jedi/api/classes.py @@ -749,6 +749,24 @@ class Completion(BaseName): return super().type + def get_completion_prefix_length(self): + """ + Returns the length of the prefix being completed. + For example, completing ``isinstance``:: + + isinstan# <-- Cursor is here + + would return 8, because len('isinstan') == 8. + + Assuming the following function definition:: + + def foo(param=0): + pass + + completing ``foo(par`` would return 3. + """ + return self._like_name_length + def __repr__(self): return '<%s: %s>' % (type(self).__name__, self._name.get_public_name())