aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/prompt-toolkit/py3/prompt_toolkit/completion/deduplicate.py
diff options
context:
space:
mode:
authorshadchin <shadchin@yandex-team.ru>2022-02-10 16:44:39 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:44:39 +0300
commite9656aae26e0358d5378e5b63dcac5c8dbe0e4d0 (patch)
tree64175d5cadab313b3e7039ebaa06c5bc3295e274 /contrib/python/prompt-toolkit/py3/prompt_toolkit/completion/deduplicate.py
parent2598ef1d0aee359b4b6d5fdd1758916d5907d04f (diff)
downloadydb-e9656aae26e0358d5378e5b63dcac5c8dbe0e4d0.tar.gz
Restoring authorship annotation for <shadchin@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/python/prompt-toolkit/py3/prompt_toolkit/completion/deduplicate.py')
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/completion/deduplicate.py86
1 files changed, 43 insertions, 43 deletions
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/completion/deduplicate.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/completion/deduplicate.py
index b717d90bb08..6ef95224a6c 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/completion/deduplicate.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/completion/deduplicate.py
@@ -1,43 +1,43 @@
-from typing import Iterable, Set
-
-from prompt_toolkit.document import Document
-
-from .base import CompleteEvent, Completer, Completion
-
-__all__ = ["DeduplicateCompleter"]
-
-
-class DeduplicateCompleter(Completer):
- """
- Wrapper around a completer that removes duplicates. Only the first unique
- completions are kept.
-
- Completions are considered to be a duplicate if they result in the same
- document text when they would be applied.
- """
-
- def __init__(self, completer: Completer) -> None:
- self.completer = completer
-
- def get_completions(
- self, document: Document, complete_event: CompleteEvent
- ) -> Iterable[Completion]:
- # Keep track of the document strings we'd get after applying any completion.
- found_so_far: Set[str] = set()
-
- for completion in self.completer.get_completions(document, complete_event):
- text_if_applied = (
- document.text[: document.cursor_position + completion.start_position]
- + completion.text
- + document.text[document.cursor_position :]
- )
-
- if text_if_applied == document.text:
- # Don't include completions that don't have any effect at all.
- continue
-
- if text_if_applied in found_so_far:
- continue
-
- found_so_far.add(text_if_applied)
- yield completion
+from typing import Iterable, Set
+
+from prompt_toolkit.document import Document
+
+from .base import CompleteEvent, Completer, Completion
+
+__all__ = ["DeduplicateCompleter"]
+
+
+class DeduplicateCompleter(Completer):
+ """
+ Wrapper around a completer that removes duplicates. Only the first unique
+ completions are kept.
+
+ Completions are considered to be a duplicate if they result in the same
+ document text when they would be applied.
+ """
+
+ def __init__(self, completer: Completer) -> None:
+ self.completer = completer
+
+ def get_completions(
+ self, document: Document, complete_event: CompleteEvent
+ ) -> Iterable[Completion]:
+ # Keep track of the document strings we'd get after applying any completion.
+ found_so_far: Set[str] = set()
+
+ for completion in self.completer.get_completions(document, complete_event):
+ text_if_applied = (
+ document.text[: document.cursor_position + completion.start_position]
+ + completion.text
+ + document.text[document.cursor_position :]
+ )
+
+ if text_if_applied == document.text:
+ # Don't include completions that don't have any effect at all.
+ continue
+
+ if text_if_applied in found_so_far:
+ continue
+
+ found_so_far.add(text_if_applied)
+ yield completion