Skip to content
Myr

Fix a bug where explicitly ignored lines weren't honored by the renderer

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

authored by Christian Rocha · committed by Christian Rocha · parent b2c726a · Browse files · 1 file+14 added−20 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+14 added−20 removed

  • other:+14 added−20 removed

1 file+14 added−20 removed

modified:standard_renderer.go+14 added-20 removed
108 unmodified lines
109110 // Clear any lines we painted in the last render.111 if r.linesRendered > 0 {112 for i := r.linesRendered - 1; i > 0; i-- {113 // Determine if we should skip rendering for this line. We can skip114 // for two reasons:115 //116 // 1. We've explicitly set this line to be ignored so we can render117 // it elsewhere (for example, via the performance scroll methods118 // like insertTop and insertBottom).119 //120 // 2. The new line is the same as the old line, in which case we121 // can skip rendering for this line as a performance optimization.122 _, ignoreLine := r.ignoreLines[i]123124 if ignoreLine ||125 // Number of lines did not increase126 (len(newLines) <= len(oldLines) &&127 // Indexes available for lookup (guard against panics)128 len(newLines) > i && len(oldLines) > i &&129 // Lines are identical130 (newLines[i] == oldLines[i])) {113 // If the number of lines we want to render hasn't increased and114 // new line is the same as the old line we can skip rendering for115 // this line as a performance optimization.116 if (len(newLines) <= len(oldLines)) && (len(newLines) > i && len(oldLines) > i) && (newLines[i] == oldLines[i]) {117 skipLines[i] = struct{}{}132 } else {118 } else if _, exists := r.ignoreLines[i]; !exists {119 clearLine(out)120 }121122 cursorUp(out)123 }124139 if _, exists := skipLines[0]; !exists {125 if _, exists := r.ignoreLines[0]; !exists {126 // We need to return to the start of the line here to properly127 // erase it. Going back the entire width of the terminal will128 // usually be farther than we need to go, but terminal emulators129 // will stop the cursor at the start of the line as a rule.
6 unmodified lines
136 clearLine(out)137 }138 }139140 // Merge the set of lines we're skipping as a rendering optimization with141 // the set of lines we've explicitly asked the renderer to ignore.142 if r.ignoreLines != nil {143 for k, v := range r.ignoreLines {144 skipLines[k] = v145 }146 }147148 r.linesRendered = 0149150 // Paint new lines151 for i := 0; i < len(newLines); i++ {
285 unmodified lines