Skip to content

Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows

Reimplement Status column alignment for 8-position grid

Maximilian Roos4fbe488ae779
diff --git a/src/commands/list/model.rs b/src/commands/list/model.rs
index c4f084644..aeac070f0 100644
--- a/src/commands/list/model.rs
+++ b/src/commands/list/model.rs
@@ -534,42 +534,50 @@ impl serde::Serialize for GitOperation {
}
/// Tracks which status symbol positions are actually used across all items
+/// and the maximum width needed for each position.
///
-/// This allows the Status column to only allocate space for positions that
-/// have data, rather than reserving space for all possible positions.
+/// This allows the Status column to:
+/// 1. Only allocate space for positions that have data
+/// 2. Pad each position to a consistent width for vertical alignment
///
-/// Uses a bit array for compact representation (8 positions = 8 bits).
+/// Stores maximum character width for each of 8 positions (including user status).
+/// A width of 0 means the position is unused.
#[derive(Debug, Clone, Copy, Default)]
pub struct PositionMask {
- /// Bit array: [0a, 0b, 0c, 0d, 1, 2, 3, 4]
- positions: [bool; 8],
+ /// Maximum width for each position: [0, 1, 2, 3, 4, 5, 6, 7]
+ /// 0 = position unused, >0 = max characters needed
+ widths: [usize; 8],
}
impl PositionMask {
- const POS_0A_CONFLICTS: usize = 0;
- const POS_0B_BRANCH_STATE: usize = 1;
+ const POS_3_WORKING_TREE: usize = 0;
+ const POS_0A_CONFLICTS: usize = 1;
const POS_0C_GIT_OPERATION: usize = 2;
- const POS_0D_WORKTREE_ATTRS: usize = 3;
- const POS_1_MAIN_DIVERGENCE: usize = 4;
- const POS_2_UPSTREAM_DIVERGENCE: usize = 5;
- const POS_3_WORKING_TREE: usize = 6;
+ const POS_1_MAIN_DIVERGENCE: usize = 3;
+ const POS_2_UPSTREAM_DIVERGENCE: usize = 4;
+ const POS_0B_BRANCH_STATE: usize = 5;
+ const POS_0D_WORKTREE_ATTRS: usize = 6;
const POS_4_USER_STATUS: usize = 7;
/// Full mask with all positions enabled (for JSON output)
- pub const FULL: Self = Self {
- positions: [true; 8],
- };
+ /// Uses width of 1 for each position as a placeholder
+ pub const FULL: Self = Self { widths: [1; 8] };
- /// Merge this mask with another, keeping positions that are used in either
+ /// Merge this mask with another, keeping the maximum width for each position
pub fn merge(&mut self, other: &Self) {
- for (i, &other_val) in other.positions.iter().enumerate() {
- self.positions[i] |= other_val;
+ for (i, &other_width) in other.widths.iter().enumerate() {
+ self.widths[i] = self.widths[i].max(other_width);
}
}
- /// Check if a position is included in the mask
+ /// Check if a position is included in the mask (width > 0)
fn includes(&self, pos: usize) -> bool {
- self.positions[pos]
+ self.widths[pos] > 0
+ }
+
+ /// Get the width allocated for a position
+ fn width(&self, pos: usize) -> usize {
+ self.widths[pos]
}
}
@@ -664,62 +672,86 @@ impl StatusSymbols {
}
// Build list of (position_index, content, has_data) tuples
+ // Ordered by importance/actionability
+ let conflicts_str = if self.has_conflicts {
+ "=".to_string()
+ } else {
+ String::new()
+ };
+ let git_operation_str = self.git_operation.to_string();
+ let main_divergence_str = self.main_divergence.to_string();
+ let upstream_divergence_str = self.upstream_divergence.to_string();
+ let branch_state_str = self.branch_state.to_string();
+ let user_status_str = self.user_status.as_deref().unwrap_or("").to_string();
+
let positions_data = [
(
- PositionMask::POS_0A_CONFLICTS,
- if self.has_conflicts { "=" } else { "" },
- self.has_conflicts,
+ PositionMask::POS_3_WORKING_TREE,
+ &self.working_tree,
+ !self.working_tree.is_empty(),
),
(
- PositionMask::POS_0B_BRANCH_STATE,
- &self.branch_state.to_string(),
- self.branch_state != BranchState::None,
+ PositionMask::POS_0A_CONFLICTS,
+ &conflicts_str,
+ self.has_conflicts,
),
(
PositionMask::POS_0C_GIT_OPERATION,
- &self.git_operation.to_string(),
+ &git_operation_str,
self.git_operation != GitOperation::None,
),
- (
- PositionMask::POS_0D_WORKTREE_ATTRS,
- &self.worktree_attrs,
- !self.worktree_attrs.is_empty(),
- ),
(
PositionMask::POS_1_MAIN_DIVERGENCE,
- &self.main_divergence.to_string(),
+ &main_divergence_str,
self.main_divergence != MainDivergence::None,
),
(
PositionMask::POS_2_UPSTREAM_DIVERGENCE,
- &self.upstream_divergence.to_string(),
+ &upstream_divergence_str,
self.upstream_divergence != UpstreamDivergence::None,
),
(
- PositionMask::POS_3_WORKING_TREE,
- &self.working_tree,
- !self.working_tree.is_empty(),
+ PositionMask::POS_0B_BRANCH_STATE,
+ &branch_state_str,
+ self.branch_state != BranchState::None,
+ ),
+ (
+ PositionMask::POS_0D_WORKTREE_ATTRS,
+ &self.worktree_attrs,
+ !self.worktree_attrs.is_empty(),
),
(
PositionMask::POS_4_USER_STATUS,
- self.user_status.as_deref().unwrap_or(""),
+ &user_status_str,
self.user_status.is_some(),
),
];
- // Grid-based rendering: each position in mask gets exactly one column
- // - If row has content at position: append content (may be multiple chars like "?!+")
- // - If row has no content at position: append single space
- // - No trimming: grid fills all columns defined by mask
+ // Grid-based rendering with padding: each position gets a fixed-width column
+ // - If row has content at position: append content, then pad to allocated width
+ // - If row has no content at position: fill with spaces to allocated width
+ use unicode_width::UnicodeWidthStr;
+
for (pos, content, has_data) in positions_data.iter() {
if !mask.includes(*pos) {
continue; // Skip positions not in mask
}
+ let allocated_width = mask.width(*pos);
+
if *has_data {
result.push_str(content);
+ // Pad to allocated width (use saturating_sub to handle edge cases)
+ let content_width = content.width();
+ let padding = allocated_width.saturating_sub(content_width);
+ for _ in 0..padding {
+ result.push(' ');
+ }
} else {
- result.push(' '); // Fill empty column with space
+ // Fill empty column with spaces
+ for _ in 0..allocated_width {
+ result.push(' ');
+ }
}
}
@@ -728,18 +760,22 @@ impl StatusSymbols {
/// Derive a position mask that tracks which symbol slots contain data.
pub fn position_mask(&self) -> PositionMask {
- let mut positions = [false; 8];
- positions[PositionMask::POS_0A_CONFLICTS] = self.has_conflicts;
- positions[PositionMask::POS_0B_BRANCH_STATE] = self.branch_state != BranchState::None;
- positions[PositionMask::POS_0C_GIT_OPERATION] = self.git_operation != GitOperation::None;
- positions[PositionMask::POS_0D_WORKTREE_ATTRS] = !self.worktree_attrs.is_empty();
- positions[PositionMask::POS_1_MAIN_DIVERGENCE] =
- self.main_divergence != MainDivergence::None;
- positions[PositionMask::POS_2_UPSTREAM_DIVERGENCE] =
- self.upstream_divergence != UpstreamDivergence::None;
- positions[PositionMask::POS_3_WORKING_TREE] = !self.working_tree.is_empty();
- positions[PositionMask::POS_4_USER_STATUS] = self.user_status.is_some();
- PositionMask { positions }
+ use unicode_width::UnicodeWidthStr;
+
+ let mut widths = [0; 8];
+
+ widths[PositionMask::POS_3_WORKING_TREE] = self.working_tree.width();
+ widths[PositionMask::POS_0A_CONFLICTS] = if self.has_conflicts { 1 } else { 0 };
+ widths[PositionMask::POS_0C_GIT_OPERATION] = self.git_operation.to_string().width();
+ widths[PositionMask::POS_1_MAIN_DIVERGENCE] = self.main_divergence.to_string().width();
+ widths[PositionMask::POS_2_UPSTREAM_DIVERGENCE] =
+ self.upstream_divergence.to_string().width();
+ widths[PositionMask::POS_0B_BRANCH_STATE] = self.branch_state.to_string().width();
+ widths[PositionMask::POS_0D_WORKTREE_ATTRS] = self.worktree_attrs.width();
+ widths[PositionMask::POS_4_USER_STATUS] =
+ self.user_status.as_ref().map(|s| s.width()).unwrap_or(0);
+
+ PositionMask { widths }
}
/// Check if symbols are empty
diff --git a/src/commands/list/status_column_tests.rs b/src/commands/list/status_column_tests.rs
index 6f6d8fcb2..b8dd138bc 100644
--- a/src/commands/list/status_column_tests.rs
+++ b/src/commands/list/status_column_tests.rs
@@ -80,9 +80,9 @@ mod status_column_rendering_tests {
fn test_two_different_positions_align() {
use super::super::model::{BranchState, StatusSymbols};
- // Position mask: [0b, 3] → 2-column grid
- // Row 1: symbol at position 0b (col 0)
- // Row 2: symbol at position 3 (col 1)
+ // Position mask: [0 (working tree), 5 (branch state)] → 2-column grid
+ // Row 1: symbol at position 5 (col 1)
+ // Row 2: symbol at position 0 (col 0)
// Create mask from row that has both positions
let mask_builder = StatusSymbols {
@@ -92,19 +92,19 @@ mod status_column_rendering_tests {
};
let mask = mask_builder.position_mask();
- // Row 1: only position 0b
+ // Row 1: only position 5 (branch state)
let row1 = StatusSymbols {
branch_state: BranchState::MatchesMain,
..Default::default()
};
- assert_eq!(row1.render_with_mask(&mask), "≡ ");
+ assert_eq!(row1.render_with_mask(&mask), " ≡");
- // Row 2: only position 3
+ // Row 2: only position 0 (working tree)
let row2 = StatusSymbols {
working_tree: "!".to_string(),
..Default::default()
};
- assert_eq!(row2.render_with_mask(&mask), " !");
+ assert_eq!(row2.render_with_mask(&mask), "! ");
}
/// Test 4: Same position symbols - single column grid
@@ -145,18 +145,18 @@ mod status_column_rendering_tests {
}
/// Test 5: Multiple symbols in one row fill multiple columns
- /// Mask [0b, 3] creates 2-column grid:
- /// - Column 0 = position 0b
- /// - Column 1 = position 3
- // Row 1: ≡? (both positions filled)
- // Expected: "≡?" (col 0=≡, col 1=?)
+ /// Mask [0 (working tree), 5 (branch state)] creates 2-column grid:
+ /// - Column 0 = position 0 (working tree)
+ /// - Column 1 = position 5 (branch state)
+ // Row 1: ?≡ (both positions filled)
+ // Expected: "?≡" (col 0=?, col 1=≡)
#[test]
fn test_multiple_symbols_one_row() {
use super::super::model::{BranchState, StatusSymbols};
- // Position mask: [0b, 3] → 2-column grid
+ // Position mask: [0 (working tree), 5 (branch state)] → 2-column grid
// Row 1: symbols at both positions
- // Expected: "≡?" (both columns filled, no spaces)
+ // Expected: "?≡" (both columns filled, no spaces)
let row = StatusSymbols {
branch_state: BranchState::MatchesMain,
working_tree: "?".to_string(),
@@ -164,24 +164,24 @@ mod status_column_rendering_tests {
};
let mask = row.position_mask();
- assert_eq!(row.render_with_mask(&mask), "≡?");
+ assert_eq!(row.render_with_mask(&mask), "?≡");
}
/// Test 6: Grid with some columns empty
- /// Mask [0b, 3] creates 2-column grid:
- /// - Column 0 = position 0b
- /// - Column 1 = position 3
- // Row 1: ≡ (only position 0b)
- // Row 2: ≡! (both positions)
+ /// Mask [0 (working tree), 5 (branch state)] creates 2-column grid:
+ /// - Column 0 = position 0 (working tree)
+ /// - Column 1 = position 5 (branch state)
+ // Row 1: ≡ (only position 5)
+ // Row 2: !≡ (both positions)
// Expected:
- // Row 1: "≡ " (col 0=≡, col 1=space)
- // Row 2: "≡!" (col 0=≡, col 1=!)
+ // Row 1: " ≡" (col 0=space, col 1=≡)
+ // Row 2: "!≡" (col 0=!, col 1=≡)
#[test]
fn test_multiple_symbols_with_position_gap() {
use super::super::model::{BranchState, StatusSymbols};
- // Position mask: [0b, 3] → 2-column grid
- // Row 1: col 0 filled, col 1 empty
+ // Position mask: [0 (working tree), 5 (branch state)] → 2-column grid
+ // Row 1: col 1 filled, col 0 empty
// Row 2: both columns filled
// Create mask from row with both positions
@@ -192,12 +192,12 @@ mod status_column_rendering_tests {
};
let mask = mask_builder.position_mask();
- // Row 1: only position 0b
+ // Row 1: only position 5 (branch state)
let row1 = StatusSymbols {
branch_state: BranchState::MatchesMain,
..Default::default()
};
- assert_eq!(row1.render_with_mask(&mask), "≡ ");
+ assert_eq!(row1.render_with_mask(&mask), " ≡");
// Row 2: both positions
let row2 = StatusSymbols {
@@ -205,7 +205,7 @@ mod status_column_rendering_tests {
working_tree: "!".to_string(),
..Default::default()
};
- assert_eq!(row2.render_with_mask(&mask), "≡!");
+ assert_eq!(row2.render_with_mask(&mask), "!≡");
}
/// Test 12: Empty status (no symbols, no user status)
@@ -224,22 +224,22 @@ mod status_column_rendering_tests {
}
/// Test 14: Three positions create 3-column grid
- /// Mask [0b, 1, 3] creates 3-column grid:
- /// - Column 0 = position 0b
- /// - Column 1 = position 1
- /// - Column 2 = position 3
- // Row 1: ≡ (position 0b)
- // Row 2: ↓ (position 1)
- // Row 3: ! (position 3)
+ /// Mask [0 (working tree), 3 (main divergence), 5 (branch state)] creates 3-column grid:
+ /// - Column 0 = position 0 (working tree)
+ /// - Column 1 = position 3 (main divergence)
+ /// - Column 2 = position 5 (branch state)
+ // Row 1: ≡ (position 5)
+ // Row 2: ↓ (position 3)
+ // Row 3: ! (position 0)
// Expected:
- // Row 1: "≡ " (col 0=≡, col 1=space, col 2=space)
+ // Row 1: " ≡" (col 0=space, col 1=space, col 2=≡)
// Row 2: " ↓ " (col 0=space, col 1=↓, col 2=space)
- // Row 3: " !" (col 0=space, col 1=space, col 2=!)
+ // Row 3: "! " (col 0=!, col 1=space, col 2=space)
#[test]
fn test_three_different_positions() {
use super::super::model::{BranchState, MainDivergence, StatusSymbols};
- // Position mask: [0b, 1, 3] → 3-column grid
+ // Position mask: [0 (working tree), 3 (main divergence), 5 (branch state)] → 3-column grid
// Create mask from all three positions
let mask_builder = StatusSymbols {
branch_state: BranchState::MatchesMain,
@@ -249,38 +249,38 @@ mod status_column_rendering_tests {
};
let mask = mask_builder.position_mask();
- // Row 1: only position 0b
+ // Row 1: only position 5 (branch state)
let row1 = StatusSymbols {
branch_state: BranchState::MatchesMain,
..Default::default()
};
- assert_eq!(row1.render_with_mask(&mask), "≡ ");
+ assert_eq!(row1.render_with_mask(&mask), " ≡");
- // Row 2: only position 1
+ // Row 2: only position 3 (main divergence)
let row2 = StatusSymbols {
main_divergence: MainDivergence::Behind,
..Default::default()
};
assert_eq!(row2.render_with_mask(&mask), " ↓ ");
- // Row 3: only position 3
+ // Row 3: only position 0 (working tree)
let row3 = StatusSymbols {
working_tree: "!".to_string(),
..Default::default()
};
- assert_eq!(row3.render_with_mask(&mask), " !");
+ assert_eq!(row3.render_with_mask(&mask), "! ");
}
- /// Test 15: Adjacent positions (0b and 0c)
- // Row 1: ≡↻ (position 0b + 0c, adjacent)
- // Expected: "≡↻"
+ /// Test 15: Adjacent positions (2 git_operation and 5 branch_state)
+ // Row 1: ↻≡ (position 2 + 5, git operation first in render order)
+ // Expected: "↻≡"
#[test]
fn test_adjacent_positions_no_space() {
use super::super::model::{BranchState, GitOperation, StatusSymbols};
- // Symbols: [≡↻]
- // Position mask: 0b + 0c (adjacent)
- // Expected: "≡↻" (no space between adjacent positions)
+ // Symbols: [↻≡]
+ // Position mask: 2 (git_operation) + 5 (branch_state)
+ // Expected: "↻≡" (git operation renders before branch state)
let row = StatusSymbols {
branch_state: BranchState::MatchesMain,
git_operation: GitOperation::Rebase,
@@ -288,45 +288,49 @@ mod status_column_rendering_tests {
};
let mask = row.position_mask();
- assert_eq!(row.render_with_mask(&mask), "≡↻");
+ assert_eq!(row.render_with_mask(&mask), "↻≡");
}
/// Test 16: Non-adjacent positions with all filled
- // Row 1: ≡!+ (position 0b + 3 + working tree continuation)
- // Expected: "≡!+"
+ // Row 1: !+≡ (position 0 working tree + position 5 branch state)
+ // Expected: "!+≡"
#[test]
fn test_all_positions_filled() {
use super::super::model::{BranchState, StatusSymbols};
- // Symbols: [≡!+]
- // Position mask: 0b + 3 (+ continuation)
- // Expected: "≡!+" (no spaces, all positions filled)
+ // Symbols: [!+≡]
+ // Position mask: 0 (working tree) + 5 (branch state)
+ // Expected: "!+≡" (no spaces, all positions filled, working tree renders first)
let row = StatusSymbols {
branch_state: BranchState::MatchesMain,
- working_tree: "!+".to_string(), // Multiple symbols at position 3
+ working_tree: "!+".to_string(), // Multiple symbols at position 0
..Default::default()
};
let mask = row.position_mask();
- assert_eq!(row.render_with_mask(&mask), "≡!+");
+ assert_eq!(row.render_with_mask(&mask), "!+≡");
}
/// Test 17: Real-world complex case 1
- // Row 1: ≡? + 🤖 (synced branch + working tree untracked + user status)
- // Row 2: ! (uncommitted changes only)
- // Row 3: ↓!+ (behind main + uncommitted + working tree added)
+ /// 3-column grid: [0 (working tree), 3 (main divergence), 5 (branch state)]
+ /// - Column 0 = position 0 (working tree, max width=2 for "!+")
+ /// - Column 1 = position 3 (main divergence, width=1)
+ /// - Column 2 = position 5 (branch state, width=1)
+ // Row 1: ? ≡ (working tree + branch state, no main divergence)
+ // Row 2: ! (working tree only)
+ // Row 3: !+↓ (working tree + main divergence, no branch state)
// Expected:
- // Row 1: "≡?🤖"
- // Row 2: " !"
- // Row 3: "↓!+"
+ // Row 1: "? ≡" (col 0=? padded to 2, col 1=space, col 2=≡)
+ // Row 2: "! " (col 0=! padded to 2, col 1=space, col 2=space)
+ // Row 3: "!+↓ " (col 0=!+ width 2, col 1=↓, col 2=space)
#[test]
fn test_real_world_complex_1() {
use super::super::model::{BranchState, MainDivergence, StatusSymbols};
- // Position mask: 0b + 1 + 3 (3-column grid)
- // Row 1: 0b=≡, 3=?, user=🤖 (user status tested separately)
- // Row 2: 3=!
- // Row 3: 1=↓, 3=!+
+ // Position mask: 0 (working tree) + 3 (main divergence) + 5 (branch state) (3-column grid)
+ // Row 1: 0=?, 5=≡, user=🤖 (user status tested separately)
+ // Row 2: 0=!
+ // Row 3: 0=!+, 3=↓
// Create mask from all positions
let mask_builder = StatusSymbols {
@@ -337,47 +341,47 @@ mod status_column_rendering_tests {
};
let mask = mask_builder.position_mask();
- // Row 1: position 0b and 3 (note: user status alignment tested separately)
+ // Row 1: position 0 (working tree) and 5 (branch state) (note: user status alignment tested separately)
let row1 = StatusSymbols {
branch_state: BranchState::MatchesMain,
working_tree: "?".to_string(),
..Default::default()
};
- assert_eq!(row1.render_with_mask(&mask), "≡ ?");
+ assert_eq!(row1.render_with_mask(&mask), "? ≡");
- // Row 2: only position 3
+ // Row 2: only position 0 (working tree)
let row2 = StatusSymbols {
working_tree: "!".to_string(),
..Default::default()
};
- assert_eq!(row2.render_with_mask(&mask), " !");
+ assert_eq!(row2.render_with_mask(&mask), "! ");
- // Row 3: position 1 and 3
+ // Row 3: position 0 (working tree) and 3 (main divergence)
let row3 = StatusSymbols {
main_divergence: MainDivergence::Behind,
working_tree: "!+".to_string(),
..Default::default()
};
- assert_eq!(row3.render_with_mask(&mask), " ↓!+");
+ assert_eq!(row3.render_with_mask(&mask), "!+↓ ");
}
/// Test 18: THE FAILING TEST - 2-column grid with partial fills
- /// Mask [0b, 3] creates 2-column grid:
- /// - Column 0 = position 0b
- /// - Column 1 = position 3
- // Row 1: ≡? (synced + untracked)
+ /// Mask [0 (working tree), 5 (branch state)] creates 2-column grid:
+ /// - Column 0 = position 0 (working tree)
+ /// - Column 1 = position 5 (branch state)
+ // Row 1: ?≡ (untracked + synced)
// Row 2: ! (uncommitted only)
// Expected:
- // Row 1: "≡?" (col 0=≡, col 1=?)
- // Row 2: " !" (col 0=space, col 1=!)
+ // Row 1: "?≡" (col 0=?, col 1=≡)
+ // Row 2: "! " (col 0=!, col 1=space)
#[test]
fn test_real_world_extreme_diffs() {
use super::super::model::{BranchState, StatusSymbols};
// This is the actual failing test case from spacing_edge_cases
- // Position mask: [0b, 3] → 2-column grid
- // Row 1 (huge): symbols at positions 0b (≡) and 3 (?)
- // Row 2 (tiny): symbol at position 3 (!) only
+ // Position mask: [0 (working tree), 5 (branch state)] → 2-column grid
+ // Row 1 (huge): symbols at positions 0 (?) and 5 (≡)
+ // Row 2 (tiny): symbol at position 0 (!) only
// Create mask from row with both positions
let mask_builder = StatusSymbols {
@@ -393,38 +397,38 @@ mod status_column_rendering_tests {
working_tree: "?".to_string(),
..Default::default()
};
- assert_eq!(row1.render_with_mask(&mask), "≡?");
+ assert_eq!(row1.render_with_mask(&mask), "?≡");
- // Row 2: only position 3 (col 0 empty→space, col 1 filled)
+ // Row 2: only position 0 (working tree) (col 0 filled, col 1 empty→space)
let row2 = StatusSymbols {
working_tree: "!".to_string(),
..Default::default()
};
- assert_eq!(row2.render_with_mask(&mask), " !");
+ assert_eq!(row2.render_with_mask(&mask), "! ");
}
/// Test 20: Position mask creates minimal grid
- /// All positions available: 0a, 0b, 0c, 0d, 1, 2, 3 (7 total)
- /// Used positions: 0b, 3 (2 used)
- /// Mask [0b, 3] creates 2-column grid (NOT 7-column):
- /// - Column 0 = position 0b
- /// - Column 1 = position 3
- // Row 1: ≡ (only position 0b used)
- // Row 2: ! (only position 3 used)
+ /// All positions available: 0, 1, 2, 3, 4, 5, 6, 7 (8 total)
+ /// Used positions: 0 (working tree), 5 (branch state) (2 used)
+ /// Mask [0, 5] creates 2-column grid (NOT 8-column):
+ /// - Column 0 = position 0 (working tree)
+ /// - Column 1 = position 5 (branch state)
+ // Row 1: ≡ (only position 5 used)
+ // Row 2: ! (only position 0 used)
// Expected:
- // Row 1: "≡ " (2 chars: col 0=≡, col 1=space)
- // Row 2: " !" (2 chars: col 0=space, col 1=!)
+ // Row 1: " ≡" (2 chars: col 0=space, col 1=≡)
+ // Row 2: "! " (2 chars: col 0=!, col 1=space)
// NOT:
- // Row 1: "≡ " (7 chars with spaces for all positions)
+ // Row 1: " ≡" (8 chars with spaces for all positions)
#[test]
fn test_position_mask_removes_unused_positions() {
use super::super::model::{BranchState, StatusSymbols};
- // Position mask: [0b, 3] → 2-column grid
+ // Position mask: [0 (working tree), 5 (branch state)] → 2-column grid
// Only used positions create columns
- // Expected: 2-char width (NOT 7-char for all possible positions)
+ // Expected: 2-char width (NOT 8-char for all possible positions)
- // Create mask from positions 0b and 3 only
+ // Create mask from positions 0 and 5 only
let mask_builder = StatusSymbols {
branch_state: BranchState::MatchesMain,
working_tree: "!".to_string(),
@@ -432,22 +436,22 @@ mod status_column_rendering_tests {
};
let mask = mask_builder.position_mask();
- // Row 1: only position 0b
+ // Row 1: only position 5 (branch state)
let row1 = StatusSymbols {
branch_state: BranchState::MatchesMain,
..Default::default()
};
let result1 = row1.render_with_mask(&mask);
- assert_eq!(result1, "≡ ");
- assert_eq!(result1.chars().count(), 2); // 2 chars, not 7
+ assert_eq!(result1, " ≡");
+ assert_eq!(result1.chars().count(), 2); // 2 chars, not 8
- // Row 2: only position 3
+ // Row 2: only position 0 (working tree)
let row2 = StatusSymbols {
working_tree: "!".to_string(),
..Default::default()
};
let result2 = row2.render_with_mask(&mask);
- assert_eq!(result2, " !");
- assert_eq!(result2.chars().count(), 2); // 2 chars, not 7
+ assert_eq!(result2, "! ");
+ assert_eq!(result2.chars().count(), 2); // 2 chars, not 8
}
}
diff --git a/tests/integration_tests/snapshots/integration__integration_tests__bare_repository__bare_repo_list_worktrees.snap b/tests/integration_tests/snapshots/integration__integration_tests__bare_repository__bare_repo_list_worktrees.snap
index a327fdcb8..2f5970274 100644
--- a/tests/integration_tests/snapshots/integration__integration_tests__bare_repository__bare_repo_list_worktrees.snap
+++ b/tests/integration_tests/snapshots/integration__integration_tests__bare_repository__bare_repo_list_worktrees.snap
@@ -14,14 +14,14 @@ info:
LC_ALL: C
NO_COLOR: ""
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmp1ELA6g/test-config.toml
+ WORKTRUNK_CONFIG: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpGKqIBp/test-config.toml
---
success: true
exit_code: 0
----- stdout -----
Branch Status HEAD± main↕ Path Remote⇅ Commit Age Message
feature ./test-repo.feature 72413a3b 10 months ago Work on feature
-main ∅↓ ↓1 ./test-repo.main 6c3da842 10 months ago Initial commit on main
+main ↓∅ ↓1 ./test-repo.main 6c3da842 10 months ago Initial commit on main
⚪ Showing 2 worktrees
diff --git a/tests/snapshots/integration__integration_tests__list__json_with_display_fields.snap b/tests/snapshots/integration__integration_tests__list__json_with_display_fields.snap
index 4601d2c01..9570a96d0 100644
--- a/tests/snapshots/integration__integration_tests__list__json_with_display_fields.snap
+++ b/tests/snapshots/integration__integration_tests__list__json_with_display_fields.snap
@@ -16,7 +16,7 @@ info:
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpsNHhir/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpAWt3Oq/test-config.toml
---
success: true
exit_code: 0
@@ -105,7 +105,7 @@ exit_code: 0
},
"commits_display": "/u001b[32m↑2/u001b[0m /u001b[2m/u001b[31m↓2/u001b[0m",
"branch_diff_display": "/u001b[32m+1/u001b[0m",
- "status_display": " ↕ ?! ",
+ "status_display": "?! ↕ ",
"working_diff_display": "/u001b[32m+1/u001b[0m /u001b[31m-1/u001b[0m"
},
{
@@ -147,7 +147,7 @@ exit_code: 0
"user_status": null
},
"commits_display": "/u001b[2m/u001b[31m↓2/u001b[0m",
- "status_display": " ∅ ↓ "
+ "status_display": " ↓ ∅ "
}
]
diff --git a/tests/snapshots/integration__integration_tests__list__json_with_metadata.snap b/tests/snapshots/integration__integration_tests__list__json_with_metadata.snap
index acb814bd0..32e90d0a5 100644
--- a/tests/snapshots/integration__integration_tests__list__json_with_metadata.snap
+++ b/tests/snapshots/integration__integration_tests__list__json_with_metadata.snap
@@ -16,7 +16,7 @@ info:
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmphzLoxx/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpglj0lC/test-config.toml
---
success: true
exit_code: 0
@@ -107,7 +107,7 @@ exit_code: 0
"working_tree": "",
"user_status": null
},
- "status_display": " ≡ "
+ "status_display": " ≡ "
},
{
"type": "worktree",
@@ -151,7 +151,7 @@ exit_code: 0
"working_tree": "",
"user_status": null
},
- "status_display": " ≡ ⊠ "
+ "status_display": " ≡⊠ "
}
]
diff --git a/tests/snapshots/integration__integration_tests__list__json_with_user_status.snap b/tests/snapshots/integration__integration_tests__list__json_with_user_status.snap
index 26633e2f7..ff2904e16 100644
--- a/tests/snapshots/integration__integration_tests__list__json_with_user_status.snap
+++ b/tests/snapshots/integration__integration_tests__list__json_with_user_status.snap
@@ -16,7 +16,7 @@ info:
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpBMysvY/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpdnC2sy/test-config.toml
---
success: true
exit_code: 0
@@ -107,7 +107,7 @@ exit_code: 0
"working_tree": "",
"user_status": "🔧"
},
- "status_display": " ≡ 🔧"
+ "status_display": " ≡ 🔧"
},
{
"type": "worktree",
@@ -151,7 +151,7 @@ exit_code: 0
"working_tree": "",
"user_status": null
},
- "status_display": " ≡ "
+ "status_display": " ≡ "
}
]
diff --git a/tests/snapshots/integration__integration_tests__list__long_commit_message.snap b/tests/snapshots/integration__integration_tests__list__long_commit_message.snap
index 231594f00..e897f6809 100644
--- a/tests/snapshots/integration__integration_tests__list__long_commit_message.snap
+++ b/tests/snapshots/integration__integration_tests__list__long_commit_message.snap
@@ -15,14 +15,14 @@ info:
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpHrXEai/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmprFrv2K/test-config.toml
---
success: true
exit_code: 0
----- stdout -----
Branch Status HEAD± main↕ Path Remote⇅ Commit Age Message
main ./test-repo 1310bfb9 10 months ago Short message
-feature-a ∅↓ ↓1 ./feature-a f078644e 10 months ago This is a very long commit message that should test how the...
+feature-a ↓∅ ↓1 ./feature-a f078644e 10 months ago This is a very long commit message that should test how the...
⚪ Showing 2 worktrees
diff --git a/tests/snapshots/integration__integration_tests__list__readme_example_simple_list.snap b/tests/snapshots/integration__integration_tests__list__readme_example_simple_list.snap
index 8480c2fb0..586e92213 100644
--- a/tests/snapshots/integration__integration_tests__list__readme_example_simple_list.snap
+++ b/tests/snapshots/integration__integration_tests__list__readme_example_simple_list.snap
@@ -15,15 +15,15 @@ info:
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpppVUpK/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpRauRta/test-config.toml
---
success: true
exit_code: 0
----- stdout -----
Branch Status HEAD± main↕ Path Remote⇅ Commit Age Message
main ./test-repo ↑0 ↓0 b834638e 10 months ago Initial commit
-bugfix-y ↑ ↑1 ./bugfix-y 412a27c8 10 months ago Fix bug
-feature-x ↑+ +5 ↑3 ./feature-x 7fd821aa 10 months ago Add file 3
+bugfix-y ↑ ↑1 ./bugfix-y 412a27c8 10 months ago Fix bug
+feature-x +↑ +5 ↑3 ./feature-x 7fd821aa 10 months ago Add file 3
⚪ Showing 3 worktrees, 1 with changes, 2 ahead
diff --git a/tests/snapshots/integration__integration_tests__list__unicode_commit_message.snap b/tests/snapshots/integration__integration_tests__list__unicode_commit_message.snap
index 741ce8a7c..fbf8d9e9b 100644
--- a/tests/snapshots/integration__integration_tests__list__unicode_commit_message.snap
+++ b/tests/snapshots/integration__integration_tests__list__unicode_commit_message.snap
@@ -15,14 +15,14 @@ info:
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpwwvOpQ/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpfohlMP/test-config.toml
---
success: true
exit_code: 0
----- stdout -----
Branch Status HEAD± main↕ Path Remote⇅ Commit Age Message
main ./test-repo e4614cb7 10 months ago Fix bug with café ☕ handling
-feature-test ∅↓ ↓1 ./feature-test 0c53695b 10 months ago Add support for 日本語 and émoji 🎉
+feature-test ↓∅ ↓1 ./feature-test 0c53695b 10 months ago Add support for 日本語 and émoji 🎉
⚪ Showing 2 worktrees
diff --git a/tests/snapshots/integration__integration_tests__list__with_upstream_tracking.snap b/tests/snapshots/integration__integration_tests__list__with_upstream_tracking.snap
index b7b3e3ee5..147d29066 100644
--- a/tests/snapshots/integration__integration_tests__list__with_upstream_tracking.snap
+++ b/tests/snapshots/integration__integration_tests__list__with_upstream_tracking.snap
@@ -16,19 +16,20 @@ info:
GIT_EDITOR: ""
LANG: C
LC_ALL: C
+ PATH: "/var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpNXg1bA/mock-bin:/Users/maximilian/.cargo/bin:/Users/maximilian/.local/bin:/Users/maximilian/.bun/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmp3kq4au/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpNXg1bA/test-config.toml
---
success: true
exit_code: 0
----- stdout -----
Branch Status HEAD± main↕ main…± Path Remote⇅ CI Commit Age Message
main ./test-repo ↑0 ↓0 6c3da842 10 months ago Initial commit on main
-ahead ↑⇡ ↑2 +2 ./ahead ↑2 ↓0 8d8f4673 10 months ago Ahead commit 2
-behind ≡ ⇣ ./behind ↑0 ↓1 6c3da842 10 months ago Initial commit on main
-diverged ↑⇅ ↑1 +1 ./diverged ↑1 ↓1 ca7cb696 10 months ago Diverged local commit
-in-sync ≡ ./in-sync ↑0 ↓0 6c3da842 10 months ago Initial commit on main
-no-upstream ≡ ./no-upstream 6c3da842 10 months ago Initial commit on main
+ahead ↑⇡ ↑2 +2 ./ahead ↑2 ↓0 8d8f4673 10 months ago Ahead commit 2
+behind ⇣≡ ./behind ↑0 ↓1 6c3da842 10 months ago Initial commit on main
+diverged ↑⇅ ↑1 +1 ./diverged ↑1 ↓1 ca7cb696 10 months ago Diverged local commit
+in-sync ≡ ./in-sync ↑0 ↓0 6c3da842 10 months ago Initial commit on main
+no-upstream ≡ ./no-upstream 6c3da842 10 months ago Initial commit on main
⚪ Showing 6 worktrees, 2 ahead
diff --git a/tests/snapshots/integration__integration_tests__list__with_user_status.snap b/tests/snapshots/integration__integration_tests__list__with_user_status.snap
index edde92069..3219ed922 100644
--- a/tests/snapshots/integration__integration_tests__list__with_user_status.snap
+++ b/tests/snapshots/integration__integration_tests__list__with_user_status.snap
@@ -15,17 +15,17 @@ info:
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmptopHjL/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmptbUu5e/test-config.toml
---
success: true
exit_code: 0
----- stdout -----
Branch Status HEAD± main↕ Path Remote⇅ Commit Age Message
main ./test-repo b834638e 10 months ago Initial commit
-clean-no-status ≡ ./clean-no-status b834638e 10 months ago Initial commit
-clean-with-status ≡ 💬 ./clean-with-status b834638e 10 months ago Initial commit
-dirty-no-status ! +1 -1 ./dirty-no-status b834638e 10 months ago Initial commit
-dirty-with-status ≡?🤖 ./dirty-with-status b834638e 10 months ago Initial commit
+clean-no-status ≡ ./clean-no-status b834638e 10 months ago Initial commit
+clean-with-status ≡💬 ./clean-with-status b834638e 10 months ago Initial commit
+dirty-no-status ! +1 -1 ./dirty-no-status b834638e 10 months ago Initial commit
+dirty-with-status ?≡🤖 ./dirty-with-status b834638e 10 months ago Initial commit
⚪ Showing 5 worktrees, 1 with changes
diff --git a/tests/snapshots/integration__integration_tests__spacing_edge_cases__alignment_empty_diffs.snap b/tests/snapshots/integration__integration_tests__spacing_edge_cases__alignment_empty_diffs.snap
index bd7be6b74..b1051f794 100644
--- a/tests/snapshots/integration__integration_tests__spacing_edge_cases__alignment_empty_diffs.snap
+++ b/tests/snapshots/integration__integration_tests__spacing_edge_cases__alignment_empty_diffs.snap
@@ -15,16 +15,16 @@ info:
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpMe99Uc/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpJLFZ2o/test-config.toml
---
success: true
exit_code: 0
----- stdout -----
Branch Status HEAD± main↕ Path Remote⇅ Commit Age Message
main ./test-repo b834638e 10 months ago Initial commit
-also-no-changes ≡ ./also-no-changes b834638e 10 months ago Initial commit
-no-changes ≡ ./no-changes b834638e 10 months ago Initial commit
-with-changes ! +1 -1 ./with-changes b834638e 10 months ago Initial commit
+also-no-changes ≡ ./also-no-changes b834638e 10 months ago Initial commit
+no-changes ≡ ./no-changes b834638e 10 months ago Initial commit
+with-changes ! +1 -1 ./with-changes b834638e 10 months ago Initial commit
⚪ Showing 4 worktrees, 1 with changes
diff --git a/tests/snapshots/integration__integration_tests__spacing_edge_cases__alignment_extreme_diffs.snap b/tests/snapshots/integration__integration_tests__spacing_edge_cases__alignment_extreme_diffs.snap
index 504e8739a..f60e1fbe9 100644
--- a/tests/snapshots/integration__integration_tests__spacing_edge_cases__alignment_extreme_diffs.snap
+++ b/tests/snapshots/integration__integration_tests__spacing_edge_cases__alignment_extreme_diffs.snap
@@ -15,15 +15,15 @@ info:
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpbV5UUI/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpNeliRA/test-config.toml
---
success: true
exit_code: 0
----- stdout -----
Branch Status HEAD± main↕ Path Remote⇅ Commit Age Message
main ./test-repo b834638e 10 months ago Initial commit
-huge ≡? ./huge b834638e 10 months ago Initial commit
-tiny ! +1 -1 ./tiny b834638e 10 months ago Initial commit
+huge ?≡ ./huge b834638e 10 months ago Initial commit
+tiny ! +1 -1 ./tiny b834638e 10 months ago Initial commit
⚪ Showing 3 worktrees, 1 with changes
diff --git a/tests/snapshots/integration__integration_tests__spacing_edge_cases__alignment_varying_diffs.snap b/tests/snapshots/integration__integration_tests__spacing_edge_cases__alignment_varying_diffs.snap
index 6cb1d6e5f..cae01c6d6 100644
--- a/tests/snapshots/integration__integration_tests__spacing_edge_cases__alignment_varying_diffs.snap
+++ b/tests/snapshots/integration__integration_tests__spacing_edge_cases__alignment_varying_diffs.snap
@@ -15,16 +15,16 @@ info:
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpL8y9jC/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmplJ42h4/test-config.toml
---
success: true
exit_code: 0
----- stdout -----
Branch Status HEAD± main↕ Path Remote⇅ Commit Age Message
main ./test-repo b834638e 10 months ago Initial commit
-feature-large ≡? ./feature-large b834638e 10 months ago Initial commit
-feature-medium ≡? ./feature-medium b834638e 10 months ago Initial commit
-feature-small ≡? ./feature-small b834638e 10 months ago Initial commit
+feature-large ?≡ ./feature-large b834638e 10 months ago Initial commit
+feature-medium ?≡ ./feature-medium b834638e 10 months ago Initial commit
+feature-small ?≡ ./feature-small b834638e 10 months ago Initial commit
⚪ Showing 4 worktrees