aboutsummaryrefslogtreecommitdiff
path: root/data/core/commandview.lua
diff options
context:
space:
mode:
authorjgmdev <jgmdev@gmail.com>2022-06-20 10:01:28 -0400
committerjgmdev <jgmdev@gmail.com>2022-06-20 10:01:28 -0400
commit665c2cdd4d6ce87f2e998219182fc88aaa63e57e (patch)
tree74aa1184daa9630dfdcad381cc7525601e0e8502 /data/core/commandview.lua
parent173dd3aeb4891267e139dd752fada6c15abbdda9 (diff)
downloadlite-xl-665c2cdd4d6ce87f2e998219182fc88aaa63e57e.tar.gz
lite-xl-665c2cdd4d6ce87f2e998219182fc88aaa63e57e.zip
CommandView: improve performance by only drawing visible
Diffstat (limited to 'data/core/commandview.lua')
-rw-r--r--data/core/commandview.lua10
1 files changed, 5 insertions, 5 deletions
diff --git a/data/core/commandview.lua b/data/core/commandview.lua
index 545455e6..969338d9 100644
--- a/data/core/commandview.lua
+++ b/data/core/commandview.lua
@@ -334,20 +334,20 @@ local function draw_suggestions_box(self)
end
-- draw suggestion text
- local suggestion_offset = math.max(self.suggestion_idx - max_suggestions, 0)
+ local offset = math.max(self.suggestion_idx - max_suggestions, 0)
+ local last = math.min(offset + max_suggestions, #self.suggestions)
core.push_clip_rect(rx, ry, rw, rh)
- local i = 1 + suggestion_offset
- while i <= #self.suggestions do
+ local first = 1 + offset
+ for i=first, last do
local item = self.suggestions[i]
local color = (i == self.suggestion_idx) and style.accent or style.text
- local y = self.position.y - (i - suggestion_offset) * lh - dh
+ local y = self.position.y - (i - offset) * lh - dh
common.draw_text(self:get_font(), color, item.text, nil, x, y, 0, lh)
if item.info then
local w = self.size.x - x - style.padding.x
common.draw_text(self:get_font(), style.dim, item.info, "right", x, y, w, lh)
end
- i = i + 1
end
core.pop_clip_rect()
end