forked from Mirrors/bubbletea
Mutex protect buffer access in standard renderer
This commit is contained in:
parent
ac28669943
commit
a72db29ae0
|
@ -88,6 +88,9 @@ func (r *standardRenderer) listen() {
|
||||||
|
|
||||||
// flush renders the buffer.
|
// flush renders the buffer.
|
||||||
func (r *standardRenderer) flush() {
|
func (r *standardRenderer) flush() {
|
||||||
|
r.mtx.Lock()
|
||||||
|
defer r.mtx.Unlock()
|
||||||
|
|
||||||
if r.buf.Len() == 0 || r.buf.String() == r.lastRender {
|
if r.buf.Len() == 0 || r.buf.String() == r.lastRender {
|
||||||
// Nothing to do
|
// Nothing to do
|
||||||
return
|
return
|
||||||
|
@ -95,9 +98,6 @@ func (r *standardRenderer) flush() {
|
||||||
|
|
||||||
out := new(bytes.Buffer)
|
out := new(bytes.Buffer)
|
||||||
|
|
||||||
r.mtx.Lock()
|
|
||||||
defer r.mtx.Unlock()
|
|
||||||
|
|
||||||
// Clear any lines we painted in the last render.
|
// Clear any lines we painted in the last render.
|
||||||
if r.linesRendered > 0 {
|
if r.linesRendered > 0 {
|
||||||
for i := r.linesRendered - 1; i > 0; i-- {
|
for i := r.linesRendered - 1; i > 0; i-- {
|
||||||
|
|
Loading…
Reference in New Issue