aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/prompt-toolkit/py2/prompt_toolkit/completion.py
diff options
context:
space:
mode:
authorNikita Slyusarev <nslus@yandex-team.com>2022-02-10 16:46:52 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:52 +0300
commitcd77cecfc03a3eaf87816af28a33067c4f0cdb59 (patch)
tree1308e0bae862d52e0020d881fe758080437fe389 /contrib/python/prompt-toolkit/py2/prompt_toolkit/completion.py
parentcdae02d225fb5b3afbb28990e79a7ac6c9125327 (diff)
downloadydb-cd77cecfc03a3eaf87816af28a33067c4f0cdb59.tar.gz
Restoring authorship annotation for Nikita Slyusarev <nslus@yandex-team.com>. Commit 1 of 2.
Diffstat (limited to 'contrib/python/prompt-toolkit/py2/prompt_toolkit/completion.py')
-rw-r--r--contrib/python/prompt-toolkit/py2/prompt_toolkit/completion.py60
1 files changed, 30 insertions, 30 deletions
diff --git a/contrib/python/prompt-toolkit/py2/prompt_toolkit/completion.py b/contrib/python/prompt-toolkit/py2/prompt_toolkit/completion.py
index 339738ab979..8807f7b34e3 100644
--- a/contrib/python/prompt-toolkit/py2/prompt_toolkit/completion.py
+++ b/contrib/python/prompt-toolkit/py2/prompt_toolkit/completion.py
@@ -40,13 +40,13 @@ class Completion(object):
assert self.start_position <= 0
def __repr__(self):
- if self.display == self.text:
- return '%s(text=%r, start_position=%r)' % (
- self.__class__.__name__, self.text, self.start_position)
- else:
- return '%s(text=%r, start_position=%r, display=%r)' % (
- self.__class__.__name__, self.text, self.start_position,
- self.display)
+ if self.display == self.text:
+ return '%s(text=%r, start_position=%r)' % (
+ self.__class__.__name__, self.text, self.start_position)
+ else:
+ return '%s(text=%r, start_position=%r, display=%r)' % (
+ self.__class__.__name__, self.text, self.start_position,
+ self.display)
def __eq__(self, other):
return (
@@ -71,22 +71,22 @@ class Completion(object):
else:
return ''
- def new_completion_from_position(self, position):
- """
- (Only for internal use!)
- Get a new completion by splitting this one. Used by
- `CommandLineInterface` when it needs to have a list of new completions
- after inserting the common prefix.
- """
- assert isinstance(position, int) and position - self.start_position >= 0
-
- return Completion(
- text=self.text[position - self.start_position:],
- display=self.display,
- display_meta=self._display_meta,
- get_display_meta=self._get_display_meta)
-
-
+ def new_completion_from_position(self, position):
+ """
+ (Only for internal use!)
+ Get a new completion by splitting this one. Used by
+ `CommandLineInterface` when it needs to have a list of new completions
+ after inserting the common prefix.
+ """
+ assert isinstance(position, int) and position - self.start_position >= 0
+
+ return Completion(
+ text=self.text[position - self.start_position:],
+ display=self.display,
+ display_meta=self._display_meta,
+ get_display_meta=self._get_display_meta)
+
+
class CompleteEvent(object):
"""
Event that called the completer.
@@ -140,18 +140,18 @@ def get_common_complete_suffix(document, completions):
end = completion.text[:-completion.start_position]
return document.text_before_cursor.endswith(end)
- completions2 = [c for c in completions if doesnt_change_before_cursor(c)]
-
- # When there is at least one completion that changes the text before the
- # cursor, don't return any common part.
- if len(completions2) != len(completions):
- return ''
+ completions2 = [c for c in completions if doesnt_change_before_cursor(c)]
+ # When there is at least one completion that changes the text before the
+ # cursor, don't return any common part.
+ if len(completions2) != len(completions):
+ return ''
+
# Return the common prefix.
def get_suffix(completion):
return completion.text[-completion.start_position:]
- return _commonprefix([get_suffix(c) for c in completions2])
+ return _commonprefix([get_suffix(c) for c in completions2])
def _commonprefix(strings):