prompt-toolkit / prompt-toolkit/python-prompt-toolkit
Some values are lost when wrapping a custom completer.
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 10.6k
- Forks
- 815
- PR merge metrics
- No merged PRs in 30d
Description
Tried wrapping my custom completer in a FuzzyCompleter, and had some problems:
- 'document.getWordBeforeCursor()' is empty, thus not allowing me to debug, as well as flat out rejecting some completions which works unwrapped.
- some yielded Completions inexplicably don't work. I am using the "emojis" library, and in my normal completer, I return this and it works fine
x = self.data['emoji_map'][val]
val_emoji = emojis.encode(x)
yield Completion(text=val_emoji, display_meta=val, start_position=-len(word))
whereas when wrapping it, the completion doesn't show up at all. Although reversing the text and display_meta works, as in:
yield Completion(text=val, display_meta=val_emoji, start_position=-len(word))
I've therefore had to remove fuzzy matching, which is a big sad.
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 how FuzzyCompleter wraps the custom completer and handles document.getWordBeforeCursor() and yielded Completion objects. Reproduce the issue with the emojis example, comparing wrapped and unwrapped behavior; done means the wrapped completer preserves the lookup word and displays valid completions without reversing text and display_meta.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100