Skip to content

Commit d0c9ec5

Browse files
author
Test User
committed
fix(ui): restore table format for worktree list display
- Revert to original table-based layout with proper alignment - Display worktrees with Name, Branch, Modified, and Path columns - Add visual indicators: ▸ for current worktree, colored branch names - Remove unused repository_info import - Maintain consistent spacing and formatting as shown in original design
1 parent 1135ead commit d0c9ec5

1 file changed

Lines changed: 33 additions & 15 deletions

File tree

src/commands/list.rs

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use colored::*;
33

44
use crate::constants::{section_header, WARNING_NO_WORKTREES};
55
use crate::git::{GitWorktreeManager, WorktreeInfo};
6-
use crate::repository_info::get_repository_info;
76
use crate::ui::{DialoguerUI, UserInterface};
87
use crate::utils::press_any_key_to_continue;
98

@@ -94,7 +93,7 @@ pub fn list_worktrees_with_ui(manager: &GitWorktreeManager, _ui: &dyn UserInterf
9493
let worktrees = manager.list_worktrees()?;
9594

9695
println!();
97-
let header = section_header("Git Worktrees");
96+
let header = section_header("Worktrees");
9897
println!("{header}");
9998
println!();
10099

@@ -106,28 +105,47 @@ pub fn list_worktrees_with_ui(manager: &GitWorktreeManager, _ui: &dyn UserInterf
106105
return Ok(());
107106
}
108107

109-
// Display repository info
110-
let repo_info = get_repository_info();
111-
println!("Repository: {}", repo_info.bright_cyan());
112-
println!();
113-
114-
// Display worktrees
108+
// Print table header
109+
println!(
110+
" {:<27} {:<37} {} {}",
111+
"Name".bold(),
112+
"Branch".bold(),
113+
"Modified".bold(),
114+
"Path".bold()
115+
);
116+
println!(
117+
" {} {} {} {}",
118+
"-".repeat(27).dimmed(),
119+
"-".repeat(37).dimmed(),
120+
"-".repeat(8).dimmed(),
121+
"-".repeat(40).dimmed()
122+
);
123+
124+
// Display worktrees in table format
115125
for worktree in &worktrees {
126+
let current_indicator = if worktree.is_current { "▸ " } else { " " };
127+
116128
let name = if worktree.is_current {
117-
format!("{} [current]", worktree.name.bright_white().bold())
129+
worktree.name.bright_white().bold().to_string()
118130
} else {
119-
worktree.name.to_string()
131+
worktree.name.clone()
120132
};
121133

122-
let branch = worktree.branch.yellow();
134+
let branch = &worktree.branch;
135+
let modified = if worktree.has_changes { "Yes" } else { "No" };
123136
let path = worktree.path.display();
124137

125-
println!("• {name}");
126-
println!(" Branch: {branch}");
127-
println!(" Path: {path}");
128-
println!();
138+
println!(
139+
"{}{:<27} {:<37} {:<8} {}",
140+
current_indicator.green(),
141+
name,
142+
branch.yellow(),
143+
modified,
144+
path.to_string().dimmed()
145+
);
129146
}
130147

148+
println!();
131149
press_any_key_to_continue()?;
132150

133151
Ok(())

0 commit comments

Comments
 (0)