Auto suggestions not called after text deletion
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
Research direction
Reproduce the behavior with the PromptSession and AutoSuggestFoo example, then inspect src/prompt_toolkit/widgets/base.py around lines 235-246 and trace what happens after deletion. Check whether the buffer loses focus, is_done changes, or input processing is skipped; done means the unconditional suggestion remains visible after text is deleted.
Written by the indexing model from the issue text.
Description
The autosuggester for a buffer does not seem to be called after deleting text from the buffer. Instead, it is only called when inserting text.
Demonstration:
from prompt_toolkit.auto_suggest import AutoSuggest, Suggestion
from prompt_toolkit import PromptSession
def main():
session = PromptSession(
auto_suggest=AutoSuggestFoo(),
)
while True:
try:
text = session.prompt("Say something: ")
except KeyboardInterrupt:
pass # Ctrl-C pressed. Try again.
else:
break
print(f"You said: {text}")
class AutoSuggestFoo(AutoSuggest):
"""
Give suggestions based on the lines in the history.
"""
def get_suggestion(self, buffer, document):
return Suggestion(" example completion")
Expected behavior:
example completion should be shown at the end of the prompt at all times, since the completer is not conditional and it always returns example completion
Actual behavior:
example completion is only shown at the end of the prompt when we are typing text. If we delete text, the suggestion goes away until we start typing again
Diagnosis:
It seems like the completion is applied in https://github.com/prompt-toolkit/python-prompt-toolkit/blob/d8adbe9bfcf5f7e95b015d8ab12e2985b9a7822b/src/prompt_toolkit/widgets/base.py#L235-L246
Does the buffer somehow lose focus or is_done become true after deleting?
Are input_processor in a buffer only applied to newly typed text? Does this mean that all formatting doesn't get reapplied on deletion?
Is
I'm happy to trace this more, but if someone can say whether this is intentional behavior (and if so is it explicitly implemented or a consequence of the architecture) that would be very helpful. Debugging async code to determine why this the input_processor isn't being called is a bit hard.
- 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
-
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 74/100
bancolombia/sentinel#23 ·
-
test md OpenCI
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
langchain-ai/deepagents#6450 ·
-
bug client
Difficulty 2/5 1-3 hours Newbie friendliness 88/100