diff --git a/gui/buffer.go b/gui/buffer.go index 9806ea3..0eefd6c 100644 --- a/gui/buffer.go +++ b/gui/buffer.go @@ -849,6 +849,14 @@ func (b *Buffer) renderAt(ctx *strife.Renderer, rx int, ry int) { var visibleLines int = 50 + // HACK + // force a render off screen + // so we can calculate the size of characters + + if int(last_h) == 0 || int(last_w) == 0 { + last_w, last_h = ctx.String("_", -50, -50) + } + // last_h > 0 means we have done // a render. if int(last_h) > 0 && int(b.h) != 0 { @@ -875,7 +883,7 @@ func (b *Buffer) renderAt(ctx *strife.Renderer, rx int, ry int) { // char index => colour var matches map[int]syntaxRuneInfo - if b.languageInfo != nil { + if b.languageInfo != nil && len(currLine) > 0 { matches = b.syntaxHighlightLine(string(currLine)) } diff --git a/main.go b/main.go index dacaad0..8bbc9b6 100644 --- a/main.go +++ b/main.go @@ -145,7 +145,9 @@ func main() { break } - if editor.update() || config.Render.Always_Render { + shouldRender := editor.update() + + if shouldRender || config.Render.Always_Render { ctx.Clear() editor.render(ctx)