Clear the rest of line after drawing to the terminal#790
Conversation
djc
left a comment
There was a problem hiding this comment.
Could we add a default implementation to keep this semver-compatible?
|
Sure. Although the only compatible default would be a no-op, which may be slightly surprising. |
What would the behavior be for downstream impls that get the default impl? |
|
The behaviour for downstream impls that use the default will be the same as in the current version (which doesn't clear the end of the line). The only difference is if they make use of the Btw, in the future I would love it if |
Yes, I meant, how would downstreams that have their own
See discussion here: #759 (comment). In my mind the cost to doing semver-incompatible releases in this crate is relatively high, so if at all possible I'd really prefer to improve it without making semver-incompatible changes. |
The only place this crate makes use of the implementation is in this PR where the default no-op implementation would be the same as the old behaviour. I.e. if |
| } | ||
|
|
||
| fn clear_to_end_of_line(&self) -> io::Result<()> { | ||
| self.clear_chars(0) |
There was a problem hiding this comment.
Why is this the right thing to be doing? clear_chars() is documented to "[c]lear the last n characters of the current line", why does passing 0 here have the desired effect? Maybe add a comment to explain this a little?
|
After thinking about this some more, and considering the desire to not have a breaking release, I think this PR should be changed to do this unconditionally: Lines 581 to 582 in 3b0294a That would entirely avoid the need for changing Lines 572 to 574 in 3b0294a |
|
Sounds good! |
|
Ok, done and also tested via rustup's use of this crate. |
move_cursor is true|
Good stuff, thanks! |
EDIT: Updated to avoid changing the
TermLiketrait.This will help fix rust-lang/rustup#4808