Don't update lines on the terminal from a previous operation
When we handle a message that isn't tracked in the "line" map (for example, one with no ID), clear the line map. This means we won't update lines that were part of a previous, completed set of operations when doing something like pull -a. It also has the beneficial side effect of avoiding terminal glitching in these types of situations, since messages that don't get tracked in the "line" map cause the count of the number of lines to get out of sync. Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
This commit is contained in:
parent
cd655d8b48
commit
5821bbd01d
1 changed files with 13 additions and 0 deletions
|
@ -169,6 +169,12 @@ func DisplayJSONMessagesStream(in io.Reader, out io.Writer, terminalFd uintptr,
|
||||||
if jm.ID != "" && (jm.Progress != nil || jm.ProgressMessage != "") {
|
if jm.ID != "" && (jm.Progress != nil || jm.ProgressMessage != "") {
|
||||||
line, ok := ids[jm.ID]
|
line, ok := ids[jm.ID]
|
||||||
if !ok {
|
if !ok {
|
||||||
|
// NOTE: This approach of using len(id) to
|
||||||
|
// figure out the number of lines of history
|
||||||
|
// only works as long as we clear the history
|
||||||
|
// when we output something that's not
|
||||||
|
// accounted for in the map, such as a line
|
||||||
|
// with no ID.
|
||||||
line = len(ids)
|
line = len(ids)
|
||||||
ids[jm.ID] = line
|
ids[jm.ID] = line
|
||||||
if isTerminal {
|
if isTerminal {
|
||||||
|
@ -182,6 +188,13 @@ func DisplayJSONMessagesStream(in io.Reader, out io.Writer, terminalFd uintptr,
|
||||||
// <ESC>[{diff}A = move cursor up diff rows
|
// <ESC>[{diff}A = move cursor up diff rows
|
||||||
fmt.Fprintf(out, "%c[%dA", 27, diff)
|
fmt.Fprintf(out, "%c[%dA", 27, diff)
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// When outputting something that isn't progress
|
||||||
|
// output, clear the history of previous lines. We
|
||||||
|
// don't want progress entries from some previous
|
||||||
|
// operation to be updated (for example, pull -a
|
||||||
|
// with multiple tags).
|
||||||
|
ids = make(map[string]int)
|
||||||
}
|
}
|
||||||
err := jm.Display(out, isTerminal)
|
err := jm.Display(out, isTerminal)
|
||||||
if jm.ID != "" && isTerminal {
|
if jm.ID != "" && isTerminal {
|
||||||
|
|
Loading…
Reference in a new issue