From 74b016202b1989f400f536d3837c8e1259c42c33 Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Fri, 25 Apr 2025 10:36:59 +0300 Subject: Add missing bounds checks to move-workspace actions Fixes panics. --- src/layout/monitor.rs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/layout/monitor.rs') diff --git a/src/layout/monitor.rs b/src/layout/monitor.rs index 009e2860..74c83317 100644 --- a/src/layout/monitor.rs +++ b/src/layout/monitor.rs @@ -772,6 +772,10 @@ impl Monitor { } pub fn move_workspace_to_idx(&mut self, old_idx: usize, new_idx: usize) { + if self.workspaces.len() <= old_idx { + return; + } + let mut new_idx = new_idx.clamp(0, self.workspaces.len() - 1); if old_idx == new_idx { return; -- cgit