From 9190dd3ad716e113017b07405132cbe322c46aa9 Mon Sep 17 00:00:00 2001 From: Anmol Wadhwani Date: Sun, 27 Oct 2024 20:51:21 +0530 Subject: [PATCH 1/2] Add an out of bounds check for mouse-selected themes in +list-themes --- src/cli/list_themes.zig | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cli/list_themes.zig b/src/cli/list_themes.zig index 9782951db..aa77c92c1 100644 --- a/src/cli/list_themes.zig +++ b/src/cli/list_themes.zig @@ -515,7 +515,9 @@ const Preview = struct { } if (theme_list.hasMouse(mouse)) |_| { if (mouse.button == .left and mouse.type == .release) { - self.current = self.window + mouse.row; + if (self.window + mouse.row < self.filtered.items.len) { + self.current = self.window + mouse.row; + } } highlight = mouse.row; } From 70d850f8e438f314149a279b022d53d1a4474679 Mon Sep 17 00:00:00 2001 From: Anmol Wadhwani Date: Sun, 27 Oct 2024 21:40:09 +0530 Subject: [PATCH 2/2] make selection a const --- src/cli/list_themes.zig | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/cli/list_themes.zig b/src/cli/list_themes.zig index aa77c92c1..92cb57be2 100644 --- a/src/cli/list_themes.zig +++ b/src/cli/list_themes.zig @@ -515,8 +515,9 @@ const Preview = struct { } if (theme_list.hasMouse(mouse)) |_| { if (mouse.button == .left and mouse.type == .release) { - if (self.window + mouse.row < self.filtered.items.len) { - self.current = self.window + mouse.row; + const selection = self.window + mouse.row; + if (selection < self.filtered.items.len) { + self.current = selection; } } highlight = mouse.row;