Skip to content

Conversation

@myndzi
Copy link

@myndzi myndzi commented May 18, 2015

This makes the progress bar much less flickery on laggy or bursty connections over SSH, etc.

@jdan
Copy link
Collaborator

jdan commented May 19, 2015

How does this work? Won't it clear whatever it just drew?

@myndzi
Copy link
Author

myndzi commented May 19, 2015

Previously, when drawing an updated line, the code did this:

  • clear the whole line
  • go to the start of the line
  • print the new line

Now, when drawing an updated line, the code does this:

  • go to the start of the line
  • print the new line
  • clear the line from here to the end

(specifically, I'm making use of the "dir" argument in readline.clearLine: https://nodejs.org/api/readline.html#readline_readline_clearline_stream_dir)

The flicker resulted from pauses between steps 1 and 2 of the old method, and is eliminated by simply overwriting the previous characters so there is never a time when they aren't there.

@hallas
Copy link
Contributor

hallas commented May 19, 2015

From what I read it looks like it writes something, then clears the line from the point where the cursor is, clearing everything in between.

So your solution writes a new line on the old one and clears anything that might have been left over by the old write?

@myndzi
Copy link
Author

myndzi commented May 19, 2015

Yes. Not sure what you mean by "in between" - note that the first step is "go to the beginning of the line"

@jdan
Copy link
Collaborator

jdan commented May 19, 2015

Yep, way better. LGTM - thank you!

jdan added a commit that referenced this pull request May 19, 2015
Don't clear whole line every time; instead, clear everything after end of line
@jdan jdan merged commit 9f5d8fc into visionmedia:master May 19, 2015
@hallas
Copy link
Contributor

hallas commented May 19, 2015

Nice change. Thanks.

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