prompt-toolkit / prompt-toolkit/python-prompt-toolkit

messy code is displayed with prompt occasionally

Open
#496 8 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

cursor-position-response
Dominant language
Python
Stars
10.6k
Forks
815
PR merge metrics
No merged PRs in 30d

Description

jonathanslenders,

When I run prompt with below format, messy code will be displayed occasionally as below. I am not sure whether it is a bug of python-prompt-toolkit. Can you help to have a look?
Thanks a lot in advance.

Nana

^[[35;1R file size limit(MB): 50
^[[70;1R has release extension: N
^[[70;1R node name: CGF01

`class EmailValidator(Validator):
self.func = None
def validate(self, document):
if len(document.text) > 0 and document.text[-1] == "!":
return
if self.func == None:
return
tmp_val = self.func(document.text)
if len(tmp_val):
raise ValidationError(message=tmp_val,
cursor_position=len(document.text))

for key, val in self.__setMap.items():
validator = EmailValidator();
validator.func = val
text = prompt(' %s: ' %key, default='%s' %str(self.__getMapkey), validator=validator)
if len(text) > 0 and text[-1] == "!":
return True
`

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the intermittent output using the supplied prompt format, including the EmailValidator and prompt() calls. Inspect how prompt-toolkit handles terminal output and the displayed escape sequences, then confirm the behavior is consistently corrected without the messy code or control sequences.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.