From 1ff3ecb5b08b40686b0e03cf79c4233c5bf99396 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Tue, 5 Jun 2018 12:44:45 -0400 Subject: fixup statusline --- go/src/lib/statusline/ratelimit.go | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'go/src/lib/statusline/ratelimit.go') diff --git a/go/src/lib/statusline/ratelimit.go b/go/src/lib/statusline/ratelimit.go index 970f8e5..087466d 100644 --- a/go/src/lib/statusline/ratelimit.go +++ b/go/src/lib/statusline/ratelimit.go @@ -20,19 +20,25 @@ func RateLimit(sl StatusLine, d time.Duration) StatusLine { ticker := time.NewTicker(d) var oldLine string var newLine string - dirty := false + first := true for { select { case <-ticker.C: - if dirty && newLine != oldLine { + if newLine != oldLine { sl.Put(newLine) + oldLine = newLine } - dirty = false case line := <-ret.lines: - newLine = line - dirty = true + if first { + first = false + oldLine = line + newLine = line + sl.Put(line) + } else { + newLine = line + } case keep := <-ret.end1: - if keep && dirty && newLine != oldLine { + if newLine != oldLine { sl.Put(newLine) } sl.End(keep) -- cgit v1.2.3-54-g00ecf