-
Notifications
You must be signed in to change notification settings - Fork 120
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
progress: Add editMessage to allow atomic updating of tracker.Message #164
Conversation
@@ -195,13 +195,15 @@ func (p *Progress) moveCursorToTheTop(out *strings.Builder) { | |||
} | |||
|
|||
func (p *Progress) renderTracker(out *strings.Builder, t *Tracker, hint renderHint) { | |||
message := t.message() | |||
if strings.Contains(message, "\t") { | |||
t.Message = strings.Replace(message, "\t", " ", -1) |
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.
FWIW: If this PR isn't accepted, this should be switched to UpdateMessage regardless
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 missed this instance in my previous change. 😞
I think the better way to do this would be to get the message value one single time, and then use it for a single render event. Give me some time to see if I can make this work.
out.WriteRune('\n') | ||
} | ||
} | ||
|
||
func (p *Progress) renderTrackerMessage(out *strings.Builder, t *Tracker) { | ||
func (p *Progress) renderTrackerMessage(out *strings.Builder, t *Tracker, message string) { |
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.
The goal with this change is to make sure that if the renderer edits the message, that the edited message is the message that is being displayed.
While not a formal race condition, without this change if UpdateMessage was called by the user between the text.Pad/text.Snip and this point the displayed message + progressbar might (for a very short period of time) not look as expected.
Pull Request Test Coverage Report for Build 775025369
💛 - Coveralls |
Definitely not! 😄 I appreciate the contributions! |
You're going to hate me... 😎
Thanks so much for your work!