prompt-toolkit / prompt-toolkit/python-prompt-toolkit
Bug: get_word_before_cursor() doesn't return strings starting with hyphen/s
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 10.6k
- Forks
- 815
- PR merge metrics
- No merged PRs in 30d
Description
Consider a simple application as one given below.
from prompt_toolkit.completion import WordCompleter
from prompt_toolkit import prompt
mycompleter = WordCompleter(['-a', '-app', '--apple', '--apricot' ,'build', 'builder', 'buildx'])
text = prompt('prompt: ', completer=mycompleter)
print('You said: %s' % text)
Running the above code and then entering - or -- on the prompt generates completions correctly. However if a alphanumeric character is entered after the hyphen/s no completions are generated. For e.g --a does not cause --apple and --apricot to be displayed.
On testing and debugging I found out that the get_word_before_cursor() function used by WordCompleter does not correctly return the hyphenated words as specified above which causes this issue.
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.
Research direction
Start by tracing WordCompleter to the get_word_before_cursor() function and reproduce the reported behavior with '-', '--', and '--a'. Done means hyphenated words such as --apple and --apricot are returned and displayed as completions when typing their prefixes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100