From 46403bd84a8e7a35fa7bcbdc1c7b95639613888c Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Wed, 13 Sep 2023 19:37:14 +0400 Subject: [PATCH] layout: Correct view offset when swapping columns --- src/layout.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/layout.rs b/src/layout.rs index 3d85ecbe0..68feb2b83 100644 --- a/src/layout.rs +++ b/src/layout.rs @@ -1523,7 +1523,19 @@ impl Workspace { return; } + let current_x = self.view_pos(); + self.columns.swap(self.active_column_idx, new_idx); + + let new_x = self.column_x(self.active_column_idx) - PADDING; + let new_view_offset = compute_new_view_offset( + current_x, + self.view_size.w, + new_x, + self.columns[self.active_column_idx].size().w, + ); + self.view_offset = new_view_offset; + self.activate_column(new_idx); } @@ -1537,7 +1549,19 @@ impl Workspace { return; } + let current_x = self.view_pos(); + self.columns.swap(self.active_column_idx, new_idx); + + let new_x = self.column_x(self.active_column_idx) - PADDING; + let new_view_offset = compute_new_view_offset( + current_x, + self.view_size.w, + new_x, + self.columns[self.active_column_idx].size().w, + ); + self.view_offset = new_view_offset; + self.activate_column(new_idx); }