Avoid drawing hidden text in DocView:draw_line_text (#1298)

* Stop drawing text past the `DocView` edge in `DocView:draw_line_text`

* Don't add draw commands if they fall outside the latest clip

The check was previously done with the window rect, so this will reduce 
a bit more the number of commands sent.
This commit is contained in:
Guldoman
2023-08-19 12:28:48 +08:00
committed by takase1121
parent d54a5d0672
commit bddb5e274d
2 changed files with 9 additions and 3 deletions
+1
View File
@@ -422,6 +422,7 @@ function DocView:draw_line_text(line, x, y)
-- do not render newline, fixes issue #1164
if tidx == last_token then text = text:sub(1, -2) end
tx = renderer.draw_text(font, text, tx, ty, color)
if tx > self.position.x + self.size.x then break end
end
return self:get_line_height()
end