From 83e41c15b1d470d71a6ba6aaf215599ee8adecfd Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Thu, 18 Jun 2020 12:19:36 -0400 Subject: [PATCH] Create ignoreLines map on demand --- renderer.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/renderer.go b/renderer.go index 4c9af9d..e121be9 100644 --- a/renderer.go +++ b/renderer.go @@ -167,6 +167,9 @@ func (r *renderer) write(s string) { // setIngoredLines speicifies lines not to be touched by the standard Bubble Tea // renderer. func (r *renderer) setIgnoredLines(from int, to int) { + if r.ignoreLines == nil { + r.ignoreLines = make(map[int]struct{}) + } for i := from; i < to; i++ { r.ignoreLines[i] = struct{}{} } @@ -176,7 +179,7 @@ func (r *renderer) setIgnoredLines(from int, to int) { // Tea renderer. Any lines previously set to be ignored can be rendered to // again. func (r *renderer) clearIgnoredLines() { - r.ignoreLines = make(map[int]struct{}) + r.ignoreLines = nil } // insertTop effectively scrolls up. It inserts lines at the top of a given @@ -239,8 +242,7 @@ func (r *renderer) insertBottom(lines []string, topBoundary, bottomBoundary int) r.out.Write(b.Bytes()) } -// handleMessages handles internal messages for the renderer. It belongs in the -// main update loop at the program level. +// handleMessages handles internal messages for the renderer. func (r *renderer) handleMessages(msg Msg) { switch msg := msg.(type) { case WindowSizeMsg: