From 6a7c5824c395b9bf48592f758f44186055f920b5 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sat, 8 Apr 2023 22:21:55 -0700 Subject: [PATCH] bugfix: syntax highlighting in source editor I missed that comments only get highlighted at start of line. This seems a bit hacky. But it continues to trade off CPU for reduced memory footprint. --- source_text.lua | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/source_text.lua b/source_text.lua index d0b4fcc..cf3d00f 100644 --- a/source_text.lua +++ b/source_text.lua @@ -44,8 +44,13 @@ function Text.draw(State, line_index, y, startpos, hide_cursor) local lo, hi = Text.clip_selection(State, line_index, pos, pos+frag_len) Text.draw_highlight(State, line, State.left,y, pos, lo,hi) end - select_color(f) - App.screen.print(f, State.left,y) + -- render colorized text + local x = State.left + for frag in f:gmatch('%S*%s*') do + select_color(frag) + App.screen.print(frag, x,y) + x = x+App.width(frag) + end -- render cursor if necessary if not hide_cursor and line_index == State.cursor1.line then if pos <= State.cursor1.pos and pos + frag_len >= State.cursor1.pos then