From b3b1e082ac16a93f19be01604cd4d764f004267e Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Sun, 24 Sep 2023 09:42:49 +0400 Subject: layout: Preserve active column when column to the left is removed --- src/layout.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/layout.rs b/src/layout.rs index 2c0ef30f..dbcc5083 100644 --- a/src/layout.rs +++ b/src/layout.rs @@ -1459,12 +1459,21 @@ impl Workspace { let window_idx = column.windows.iter().position(|win| win == window).unwrap(); column.windows.remove(window_idx); if column.windows.is_empty() { + // FIXME: activate_column below computes current view position to compute the new view + // position, which can include the column we're removing here. This leads to unwanted + // view jumps. self.columns.remove(column_idx); if self.columns.is_empty() { return; } - self.activate_column(min(self.active_column_idx, self.columns.len() - 1)); + if self.active_column_idx > column_idx { + // A column to the left was removed; preserve the current position. + self.activate_column(self.active_column_idx - 1); + } else { + self.activate_column(min(self.active_column_idx, self.columns.len() - 1)); + } + return; } -- cgit