From 83b4d6ff1dac0d483ad1a470fef80485c151a0ea Mon Sep 17 00:00:00 2001 From: David Vazgenovich Shakaryan Date: Wed, 7 Jan 2026 15:46:45 -0800 Subject: don't redraw when cursor position doesn't change --- state.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'state.lua') diff --git a/state.lua b/state.lua index 2f609c9..8bf4ddd 100644 --- a/state.lua +++ b/state.lua @@ -85,6 +85,12 @@ end function menu_mt:set_cursor(pos, lines, opts) local pos = math.max(1, math.min(pos, #self.options)) local top = self.view_top + + if not lines then + top = pos + goto update + end + if opts and opts.centre then top = pos - math.floor((lines - 1) / 2) elseif opts and opts.keep_offset then @@ -100,8 +106,13 @@ function menu_mt:set_cursor(pos, lines, opts) top = math.max(1, math.min(top, #self.options - lines + 1)) + ::update:: + if pos == self.cursor and top == self.view_top then + return false + end self.cursor = pos self.view_top = top + return true end function menu_mt:set_sort(bool, f) -- cgit v1.2.3-70-g09d2