Skip to content

messy code is displayed with prompt occasionally #496

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
nanaal opened this issue Mar 31, 2017 · 8 comments
Open

messy code is displayed with prompt occasionally #496

nanaal opened this issue Mar 31, 2017 · 8 comments

Comments

@nanaal
Copy link

nanaal commented Mar 31, 2017

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
`

@jonathanslenders
Copy link
Member

Hi @nanaal,

This is a cursor-position-response that should have been processed, but was printed instead.
Can you please tell me which operating system and terminal application you are using?

Thanks,
Jonathan

@nanaal
Copy link
Author

nanaal commented Apr 5, 2017

Hi @jonathanslenders ,

Below are the info of operating system and terminal application.
Please help to have a check.
Thanks a lot.

Nana

[root@yywcdr-1 ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.2 (Maipo)
[root@yywcdr-1 ~]# echo $TERM
xterm

@atherra
Copy link

atherra commented Jun 19, 2017

I can also reproduce this fairly easily by triggering fast prompt redraws by mashing Enter on the prompt or when printing a large set of tabulated data.

root@fsrv02:/root>

root@fsrv02:/root>

root@fsrv02:/root>

^[[53;1R
root@fsrv02:/root>

Disabling cooked mode (#487) doesn't seem to change anything for me.

Testing https://github.com/jonathanslenders/python-prompt-toolkit/pull/339/files, I no longer see CPRs. I do, however, see seemingly random newlines between prompts (stdout proxying is on):

root@fsrv02:/root>
root@fsrv02:/root>
root@fsrv02:/root>

root@fsrv02:/root>

root@fsrv02:/root>


root@fsrv02:/root>

root@fsrv02:/root>

@asmeurer
Copy link
Contributor

Same issue as #456. I'll need to check if that PR fixes it.

@asmeurer
Copy link
Contributor

I tested the branch (it's old, so you probably have to merge with master) and it doesn't fix the problem for me. Also sometimes it prints the first prompt twice.

@atherra
Copy link

atherra commented Jun 19, 2017

Re. https://github.com/jonathanslenders/python-prompt-toolkit/pull/339/files I tested it by cherry-picking to master.

@jonathanslenders
Copy link
Member

Hi everyone, could you test whether this issue still happens on the 2.0 branch?
(Possibly you'll have to make a few small changes for using 2.0.) If that's still the case, it would be much easier to fix it there. Thanks!

@asmeurer
Copy link
Contributor

I modified my patch in #456 to work in 2.0, and it reproduced there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants