Skip to content
Myr

Re-render all lines if the total number of lines increases

Before adoption: this commit came in with the history the project adopted, so no landing records it.

If the number of lines increased there's a chance that the increase in lines caused the terminal to scroll (even in the altscreen). Because of this we must repaint everything, as skipping lines will mis-render. Thanks to @fiws for reporting this bug.

authored by Christian Rocha · committed by Christian Rocha · parent 54da548 · Browse files · 1 file+9 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+9 added−2 removed

  • other:+9 added−2 removed

1 file+9 added−2 removed

modified:standard_renderer.go+9 added-2 removed
112 unmodified lines
113 //114 // 2. The new line is the same as the old line, in which case we115 // can skip rendering for this line as a performance optimization.116 _, ignoreLine := r.ignoreLines[i]117 if ignoreLine || (len(newLines) > i && len(oldLines) > i && newLines[i] == oldLines[i]) {117118 if ignoreLine ||119 // Number of lines did not increase120 (len(newLines) <= len(oldLines) &&121 // Indexes available for lookup (guard against panics)122 len(newLines) > i && len(oldLines) > i &&123 // Lines are identical124 (newLines[i] == oldLines[i])) {125 skipLines[i] = struct{}{}126 } else {127 clearLine(out)128 }
40 unmodified lines
169 }170171 _, _ = io.WriteString(out, line)172166 if i != len(newLines)-1 {173 if i < len(newLines)-1 {174 _, _ = io.WriteString(out, "\r\n")175 }176 }177 r.linesRendered++
246 unmodified lines