From 8843bbb0c4dc4e6b52ca5d0a6592ce80be56a19c Mon Sep 17 00:00:00 2001 From: Can Celik Date: Sun, 26 Jul 2026 02:45:44 +0300 Subject: fix: improve sidebar worktree hierarchy and reordering (#1873) * fix: clarify sidebar worktree hierarchy refs #1694 * feat: reorder worktree groups as a unit refs #1694 --- src/app/state.rs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'src/app/state.rs') diff --git a/src/app/state.rs b/src/app/state.rs index 6069b8a6..17b3ae4c 100644 --- a/src/app/state.rs +++ b/src/app/state.rs @@ -1141,10 +1141,16 @@ pub struct SettingsState { pub original_theme: Option, } +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub(crate) enum WorkspaceDropTarget { + Before(usize), + End, +} + pub(crate) enum DragTarget { WorkspaceReorder { source_ws_idx: usize, - insert_idx: Option, + drop_target: Option, }, TabReorder { ws_idx: usize, @@ -2211,16 +2217,11 @@ impl AppState { match &drag.target { DragTarget::WorkspaceReorder { source_ws_idx, - insert_idx, + drop_target, } => { assert_workspace_index(*source_ws_idx, "workspace drag source"); - if let Some(insert_idx) = insert_idx { - assert!( - *insert_idx <= self.workspaces.len(), - "workspace drag insert index {} out of bounds for {} workspaces", - insert_idx, - self.workspaces.len() - ); + if let Some(WorkspaceDropTarget::Before(ws_idx)) = drop_target { + assert_workspace_index(*ws_idx, "workspace drag target"); } } DragTarget::TabReorder { -- cgit v1.2.3