lang: Refactor all the highlight helping together

Keep this cleaner and add a bit more.
This commit is contained in:
James Shubin
2025-06-07 00:23:45 -04:00
parent 2b7e9c3200
commit 55eeb50fb4
12 changed files with 35 additions and 28 deletions

View File

@@ -197,3 +197,16 @@ func (obj *Textarea) HighlightText() string {
return result.String()
}
// HighlightHelper gives the user better file/line number feedback.
func HighlightHelper(node Node, logf func(format string, v ...interface{}), err error) error {
displayer, ok := node.(TextDisplayer)
if !ok {
return err
}
if highlight := displayer.HighlightText(); highlight != "" {
logf("%s: %s", err.Error(), highlight)
}
return fmt.Errorf("%s: %s", err.Error(), displayer.Byline())
}