Skip to content
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

MultiProgress: add println and suspend implementation #351

Merged
merged 6 commits into from
Mar 4, 2022

Conversation

chris-laplante
Copy link
Collaborator

Work-in-progress pull request for implementing println. This does not currently work as nothing is printed for some reason. I have reason to believe it is due to an interaction with e46ca83, since if you change the line below to m.println("Starting...\n\n") it works.

@chris-laplante
Copy link
Collaborator Author

FYI I reverted e46ca83 locally and it fixes the problem. So I guess the goal is to find a way for that commit and this feature to coexist.

@chris-laplante
Copy link
Collaborator Author

See #205

@sigmaSd
Copy link
Contributor

sigmaSd commented Jan 14, 2022

I tried your branch and it seems to work (I tried the multi example, and it seems to print those lines), is there something needed to reproduce the issue?

I'm on linux if that matters

@chris-laplante
Copy link
Collaborator Author

@sigmaSd thanks for giving it a try! I actually did fix the issue, but forgot to mark the pull as ready for review. Sorry about that.

@chris-laplante chris-laplante marked this pull request as ready for review January 14, 2022 14:25
@chris-laplante chris-laplante changed the title MultiProgress: add WIP println implementation MultiProgress: add println implementation Jan 14, 2022
@sigmaSd
Copy link
Contributor

sigmaSd commented Jan 14, 2022

@chris-laplante thanks as well! glad its not a platform issue then, If its just about adding a new line, I guess that's expected with e46ca83, I kind of want it to work that's why I'm on the lookup for issues xD

@chris-laplante
Copy link
Collaborator Author

chris-laplante commented Jan 14, 2022

@sigmaSd there's another problem here I didn't initially see. Adding an extra space after the last line (term.write_str(" ")?; in ProgressDrawState::draw_to_term is not correct in the case of println. I noticed this while extending adding suspend, which I just pushed. Please give it a try. You will see that the println caused an extra space to be printed out, which is why the "test suspension :)" comes out with a leading space:

Starting!
 test suspension :)

So I think this pull is possibly blocked on #350.

@sigmaSd
Copy link
Contributor

sigmaSd commented Jan 14, 2022

Yes the space hack was definitly the wrong aproach, shifting the missing width increase to the wide elements seems to be the reasonable choice in #350

// `ProgressDrawState::draw_to_term` doesn't add \n to the last line, we need to add it
// ourselves. Otherwise the last line of what we print may be overwritten on next draw.
if let Some(line) = lines.last_mut() {
line.push('\n');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this still needed after af3bd31 ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing this line and using #356 seems to make it work

@chris-laplante chris-laplante changed the title MultiProgress: add println implementation (WIP) MultiProgress: add println implementation Jan 26, 2022
@djc
Copy link
Member

djc commented Feb 4, 2022

@chris-laplante did you want to rebase this? I'd like to get the release out soon.

@chris-laplante
Copy link
Collaborator Author

@chris-laplante did you want to rebase this? I'd like to get the release out soon.

Yes, absolutely. I started working on it this morning. Will finish it soon I hope.

@djc
Copy link
Member

djc commented Feb 4, 2022

Awesome, thanks!

@chris-laplante
Copy link
Collaborator Author

Not ready yet, besides the lint I am still working on diagnosing an issue...

@chris-laplante
Copy link
Collaborator Author

@djc not sure if you're getting notifications about the comment I made on my commit (if you are, I apologize for the spam). In case not, I'll repeat it here since I know you want to release soon:

If you run the 'multi' example that I modified, you'll see that only the first message is printed. The messages for when h1, h2, and h3 finish are not printed. If you change line 247 src/multi.rs to panic instead of return OK, you'll see that it's hitting this line. drawable is returning None here.

I think the issue is that ProgressDrawTarget::drawable should take the force_draw parameter, rather than Drawable::state. There is a bit of a chicken-and-egg situation going on. You need a DrawStateWrapper to manipulate the force_draw property of ProgressDrawState. But to get one, you need to call ProgressDrawTarget::drawable which (in the case of Term) is beholden to the leaky bucket.

@djc
Copy link
Member

djc commented Feb 8, 2022

Sounds reasonable. Please do it as a separate commit (or even separate PR).

@djc
Copy link
Member

djc commented Feb 10, 2022

Actually, since this doesn't change any public API, I think we can move forward with the release and add this later. I'll do another rc for a bit.

@chris-laplante
Copy link
Collaborator Author

@djc I think this is finally ready when you have a chance to take a look :)

@chris-laplante chris-laplante changed the title (WIP) MultiProgress: add println implementation MultiProgress: add println and suspend implementation Feb 23, 2022
Copy link
Member

@djc djc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly looks, some minor nits remaining!

src/in_memory.rs Show resolved Hide resolved
src/multi.rs Outdated Show resolved Hide resolved
src/multi.rs Outdated Show resolved Hide resolved
Copy link
Member

@djc djc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Good to merge?

@chris-laplante
Copy link
Collaborator Author

LGTM! Good to merge?

Yes please :)

@chris-laplante
Copy link
Collaborator Author

Would it be possible to get this merged in today? I'd love to play with this some more over the weekend :)

@djc djc merged commit d5f95b2 into console-rs:main Mar 4, 2022
@djc
Copy link
Member

djc commented Mar 4, 2022

Sorry, I somehow missed your previous comment!

@chris-laplante
Copy link
Collaborator Author

Sorry, I somehow missed your previous comment!

No prob, thanks for merging!

@chris-laplante chris-laplante deleted the cpl/multi-progress-println branch March 4, 2022 18:57
@chris-laplante
Copy link
Collaborator Author

Any chance of an rc release with these changes?

@djc
Copy link
Member

djc commented Mar 9, 2022

rc.8 is out now. 👍

@chris-laplante
Copy link
Collaborator Author

rc.8 is out now. 👍

Thanks! I appreciate it :)

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

Successfully merging this pull request may close these issues.

3 participants