diff options
Diffstat (limited to 'src/app/actions.rs')
| -rw-r--r-- | src/app/actions.rs | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/app/actions.rs b/src/app/actions.rs index d791da03..eccc8d4d 100644 --- a/src/app/actions.rs +++ b/src/app/actions.rs @@ -1193,9 +1193,18 @@ impl AppState { self.switch_workspace(prev); } - pub fn move_workspace(&mut self, source_idx: usize, insert_idx: usize) { + pub fn move_workspace(&mut self, source_idx: usize, insert_idx: usize) -> bool { if source_idx >= self.workspaces.len() || insert_idx > self.workspaces.len() { - return; + return false; + } + + let target_idx = if source_idx < insert_idx { + insert_idx - 1 + } else { + insert_idx + }; + if source_idx == target_idx { + return false; } self.mark_session_dirty(); @@ -1207,12 +1216,6 @@ impl AppState { .map(|workspace| workspace.id.clone()); let workspace = self.workspaces.remove(source_idx); - let target_idx = if source_idx < insert_idx { - insert_idx.saturating_sub(1) - } else { - insert_idx - } - .min(self.workspaces.len()); self.workspaces.insert(target_idx, workspace); self.active = active_id.and_then(|id| self.workspaces.iter().position(|ws| ws.id == id)); @@ -1220,6 +1223,7 @@ impl AppState { .and_then(|id| self.workspaces.iter().position(|ws| ws.id == id)) .unwrap_or(0); self.ensure_workspace_visible(self.selected); + true } pub fn scroll_tabs_left(&mut self) { |
