diff options
| author | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-06-29 20:39:54 +0300 |
|---|---|---|
| committer | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-06-29 20:39:54 +0300 |
| commit | 8b74fb8a12716269c76f0b503ee7db5bbec2c921 (patch) | |
| tree | e5230f94cb1e6eb70d1f00c75cd85dae8b5b9ead /src/app/actions.rs | |
| parent | 5fffc59cd8aaea1604abb90e749e58fd97acfac0 (diff) | |
feat: emit placement mutation events
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) { |
