mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Fix race with HighlightableHelper
GetRect can lead to a race condition Add a RenderFunc method so that we can call try to wrap even more of our rendering in the thread safe `QueueUpdateDraw` method
This commit is contained in:
@@ -2,7 +2,6 @@ package jenkins
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/rivo/tview"
|
||||
"github.com/wtfutil/wtf/utils"
|
||||
"github.com/wtfutil/wtf/view"
|
||||
@@ -64,14 +63,15 @@ func (widget *Widget) Render() {
|
||||
return
|
||||
}
|
||||
|
||||
title := fmt.Sprintf("%s: [red]%s", widget.CommonSettings().Title, widget.view.Name)
|
||||
|
||||
widget.Redraw(title, widget.contentFrom(widget.view), false)
|
||||
widget.RedrawFunc(widget.content)
|
||||
}
|
||||
|
||||
func (widget *Widget) contentFrom(view *View) string {
|
||||
func (widget *Widget) content() (string, string, bool) {
|
||||
title := fmt.Sprintf("%s: [red]%s", widget.CommonSettings().Title, widget.view.Name)
|
||||
|
||||
var str string
|
||||
for idx, job := range view.Jobs {
|
||||
jobs := widget.view.Jobs
|
||||
for idx, job := range jobs {
|
||||
|
||||
row := fmt.Sprintf(
|
||||
`[%s] [%s]%-6s[white]`,
|
||||
@@ -83,7 +83,7 @@ func (widget *Widget) contentFrom(view *View) string {
|
||||
str += utils.HighlightableHelper(widget.View, row, idx, len(job.Name))
|
||||
}
|
||||
|
||||
return str
|
||||
return title, str, false
|
||||
}
|
||||
|
||||
func (widget *Widget) jobColor(job *Job) string {
|
||||
|
||||
Reference in New Issue
Block a user