NestedCompleter doesn't work if there is a dash in the word
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
Research direction
Start in prompt_toolkit/completion/nested.py, focusing on NestedCompleter's WordCompleter call and its handling of the current document. Reproduce completion for the example "multi-test" and compare the proposed pattern change with existing behavior. Done means hyphenated words continue completing without breaking other nested completion cases.
Written by the indexing model from the issue text.
Description
If I have the word "multi-test", for example, auto-completion treats the dash "-" as a whitespace separator. It won't continue after "multi".
To fix this I used the following patch:
--- /usr/local/lib/python3.7/dist-packages/prompt_toolkit/completion/nested.py 2020-10-23 19:54:59.873439073 +0000
+++ NestedCompleterFixed.py 2020-10-25 14:40:35.306087935 +0000
@@ -7,6 +7,8 @@
from prompt_toolkit.completion.word_completer import WordCompleter
from prompt_toolkit.document import Document
+import re
+
__all__ = ["NestedCompleter"]
# NestedDict = Mapping[str, Union['NestedDict', Set[str], None, Completer]]
@@ -103,7 +105,8 @@
# No space in the input: behave exactly like `WordCompleter`.
else:
completer = WordCompleter(
- list(self.options.keys()), ignore_case=self.ignore_case
+ list(self.options.keys()), ignore_case=self.ignore_case,
+ pattern=re.compile(r'.*') # or else "-" breaks the completion
)
for c in completer.get_completions(document, complete_event):
yield c
I don't know if this is a correct fix but it works for me.
If this is the correct solution, then maybe you can add this as an argument in __init__().
- Dominant language
- Python
- Stars
- 10.6k
- Forks
- 815
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from prompt-toolkit/python-prompt-toolkit
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 92/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
prompt-toolkit/python-prompt-toolkit#2073 · 2 comments ·
-
Difficulty 1/5 Under an hour Newbie friendliness 65/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
prompt-toolkit/python-prompt-toolkit#1154 · 1 comment ·
All issues in prompt-toolkit/python-prompt-toolkit
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
zostera/django-bootstrap4#894 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
use-agent-os/agent-os#3276 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
zephyrproject-rtos/zephyr#119726 ·
-
area/auth bug comp/agent P3 platform/discord type/security
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
NousResearch/hermes-agent#117848 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
zilliztech/memsearch#759 ·