-
Notifications
You must be signed in to change notification settings - Fork 143
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
confirm: properly clear the terminal in case of a multi-line prompt string #166
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please convert this change to all the prompt types?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the feedback! I'm happy to, but I don't see how that makes sense.
I looked at all the other prompts, and and all of them support multi-line prompt strings without issue. This bug only manifests because when trying to clear the current prompt. Confirmation prompts do this, but none of the other prompts do. (The selection prompts, for example, do need to clear multiple lines, but don't need to clear the prompt.)
More specifically:
clear_line
method isinput.rs
; that part of code is not clearing a prompt.clear_last_lines
is used a couple of times, but always to reset the whole terminal (such asclear_last_lines(paging.capacity)?
).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that this logic feels not really specific to confirmation prompts. I'm not sure where to extract it to, though. Can you point me to a better place? Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extraction is not what I had in mind. Just copying to other prompts is enough. But as you said, looks like the other prompts don't have this bug. I will need to investigate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Investigated and looks like yes, bug only happens in this prompt. But instead of doing it like this, can you please replace
term.clear_line()
withrender.clear()
and see if that satisfies for you?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, and the bug is not specific to the combination of "report=true" and "wait_for_newline=false".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the bug is with theme renderer. We might be doing different things for confirm prompt rather than the pattern we used in other prompts. (I consider select prompt to be highly polished).
In any case, I would rather appreciate if you could fix it correctly in there. I am not interested in accepting this solution which would just increase the codebase's technical debt. With that said, I understand if you are not willing to continue anymore. In that case, you will have to wait for me to work on 0.11.0 in a few months for fixing this issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ack, fair enough. It so turned out that I had a spare moment today and looked into fixing this directly -- and the fix was reasonable; I just pushed that. Let me know if you'd like me to change anything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm.. you sure you pushed it? I don't see it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well... I thought pushing would be easy, but I managed to bork my branch. I created a new version at #175.
(If you can point me at instructions for fixing that, I'm all ears. I'm using mercurial through hg-git; sometimes things get lost in translation.)