Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
Remove left_margin parameter from gutter formatting functions
Maximilian Roos6bf336f7eb98
diff --git a/src/commands/command_approval.rs b/src/commands/command_approval.rsindex 6cf333df4..2bd5eb558 100644--- a/src/commands/command_approval.rs+++ b/src/commands/command_approval.rs@@ -129,7 +129,7 @@ fn prompt_for_batch_approval(commands: &[&HookCommand], project_id: &str) -> anyNone => format!("{INFO_SYMBOL} {phase}:"),};eprintln!("{label}");- eprint!("{}", format_bash_with_gutter(&cmd.command.template, ""));+ eprint!("{}", format_bash_with_gutter(&cmd.command.template));}// Check if stdin is a TTY before attempting to promptdiff --git a/src/commands/commit.rs b/src/commands/commit.rsindex 0ce9e2614..716998e07 100644--- a/src/commands/commit.rs+++ b/src/commands/commit.rs@@ -123,7 +123,7 @@ impl<'a> CommitGenerator<'a> {let commit_message = crate::llm::generate_commit_message(self.config)?;let formatted_message = self.format_message_for_display(&commit_message);- crate::output::gutter(format_with_gutter(&formatted_message, "", None))?;+ crate::output::gutter(format_with_gutter(&formatted_message, None))?;repo.run_command(&["commit", "-m", &commit_message]).context("Failed to commit")?;diff --git a/src/commands/config.rs b/src/commands/config.rsindex 33524ff01..b174513a9 100644--- a/src/commands/config.rs+++ b/src/commands/config.rs@@ -219,7 +219,7 @@ fn render_diagnostics(out: &mut String) -> anyhow::Result<()> {"Commit generation working (<bold>{command_display}</>)")))?;- write!(out, "{}", format_with_gutter(&message, "", None))?;+ write!(out, "{}", format_with_gutter(&message, None))?;}Err(e) => {writeln!(@@ -229,7 +229,7 @@ fn render_diagnostics(out: &mut String) -> anyhow::Result<()> {"Commit generation failed (<bold>{command_display}</>)")))?;- write!(out, "{}", format_with_gutter(&e.to_string(), "", None))?;+ write!(out, "{}", format_with_gutter(&e.to_string(), None))?;}}@@ -256,7 +256,7 @@ fn render_user_config(out: &mut String) -> anyhow::Result<()> {)?;writeln!(out)?;let default_config = "# Default configuration:\nworktree-path = \"../{{ main_worktree }}.{{ branch | sanitize }}\"";- write!(out, "{}", format_toml(default_config, ""))?;+ write!(out, "{}", format_toml(default_config))?;return Ok(());}@@ -272,7 +272,7 @@ fn render_user_config(out: &mut String) -> anyhow::Result<()> {warn_unknown_keys(out, &find_unknown_user_keys(&contents))?;// Display TOML with syntax highlighting (gutter at column 0)- write!(out, "{}", format_toml(&contents, ""))?;+ write!(out, "{}", format_toml(&contents))?;Ok(())}@@ -335,7 +335,7 @@ fn render_project_config(out: &mut String) -> anyhow::Result<()> {warn_unknown_keys(out, &find_unknown_project_keys(&contents))?;// Display TOML with syntax highlighting (gutter at column 0)- write!(out, "{}", format_toml(&contents, ""))?;+ write!(out, "{}", format_toml(&contents))?;Ok(())}@@ -394,7 +394,7 @@ fn render_shell_status(out: &mut String) -> anyhow::Result<()> {write!(out,"{}",- format_with_gutter("autoload -Uz compinit && compinit", "", None,)+ format_with_gutter("autoload -Uz compinit && compinit", None))?;}@@ -610,7 +610,7 @@ fn render_log_files(out: &mut String, repo: &Repository) -> anyhow::Result<()> {)?;if !log_dir.exists() {- write!(out, "{}", format_with_gutter("(none)", "", None))?;+ write!(out, "{}", format_with_gutter("(none)", None))?;return Ok(());}@@ -620,7 +620,7 @@ fn render_log_files(out: &mut String, repo: &Repository) -> anyhow::Result<()> {.collect();if entries.is_empty() {- write!(out, "{}", format_with_gutter("(none)", "", None))?;+ write!(out, "{}", format_with_gutter("(none)", None))?;return Ok(());}@@ -1075,16 +1075,16 @@ fn handle_state_show_table(repo: &Repository) -> anyhow::Result<()> {// Show default branch cachewriteln!(out, "{}", format_heading("DEFAULT BRANCH", None))?;match repo.default_branch() {- Ok(branch) => write!(out, "{}", format_with_gutter(&branch, "", None))?,- Err(_) => write!(out, "{}", format_with_gutter("(not cached)", "", None))?,+ Ok(branch) => write!(out, "{}", format_with_gutter(&branch, None))?,+ Err(_) => write!(out, "{}", format_with_gutter("(not cached)", None))?,}writeln!(out)?;// Show previous branch (for `wt switch -`)writeln!(out, "{}", format_heading("PREVIOUS BRANCH", None))?;match repo.get_switch_previous() {- Some(prev) => write!(out, "{}", format_with_gutter(&prev, "", None))?,- None => write!(out, "{}", format_with_gutter("(none)", "", None))?,+ Some(prev) => write!(out, "{}", format_with_gutter(&prev, None))?,+ None => write!(out, "{}", format_with_gutter("(none)", None))?,}writeln!(out)?;@@ -1092,7 +1092,7 @@ fn handle_state_show_table(repo: &Repository) -> anyhow::Result<()> {writeln!(out, "{}", format_heading("BRANCH MARKERS", None))?;let markers = get_all_markers(repo);if markers.is_empty() {- write!(out, "{}", format_with_gutter("(none)", "", None))?;+ write!(out, "{}", format_with_gutter("(none)", None))?;} else {let mut table = String::from("| Branch | Marker | Age |\n");table.push_str("|--------|--------|-----|\n");@@ -1118,7 +1118,7 @@ fn handle_state_show_table(repo: &Repository) -> anyhow::Result<()> {.then_with(|| a.0.cmp(&b.0))});if entries.is_empty() {- write!(out, "{}", format_with_gutter("(none)", "", None))?;+ write!(out, "{}", format_with_gutter("(none)", None))?;} else {// Build markdown tablelet mut table = String::from("| Branch | Status | Age | Head |\n");diff --git a/src/commands/configure_shell.rs b/src/commands/configure_shell.rsindex 6d004bff6..a975058bc 100644--- a/src/commands/configure_shell.rs+++ b/src/commands/configure_shell.rs@@ -183,10 +183,8 @@ pub fn handle_configure_shell(let _ = crate::output::print(warning_message("Completions won't work; add to ~/.zshrc before the wt line:",));- let _ = crate::output::gutter(format_bash_with_gutter(- "autoload -Uz compinit && compinit",- "",- ));+ let _ =+ crate::output::gutter(format_bash_with_gutter("autoload -Uz compinit && compinit"));}}@@ -534,7 +532,7 @@ fn prompt_for_confirmation();// Show the config line that will be added with gutter- eprint!("{}", format_bash_with_gutter(&result.config_line, ""));+ eprint!("{}", format_bash_with_gutter(&result.config_line));eprintln!(); // Blank line after each shell block}@@ -555,7 +553,7 @@ fn prompt_for_confirmation(// Show the completion content that will be writtenlet fish_completion = fish_completion_content(cmd);- eprint!("{}", format_bash_with_gutter(fish_completion.trim(), ""));+ eprint!("{}", format_bash_with_gutter(fish_completion.trim()));eprintln!(); // Blank line after}@@ -950,7 +948,6 @@ pub fn handle_show_theme() -> Result<(), String> {.map_err(|e| e.to_string())?;crate::output::gutter(format_with_gutter("[commit-generation]\ncommand = \"llm --model claude\"",- "",None,)).map_err(|e| e.to_string())?;@@ -962,7 +959,6 @@ pub fn handle_show_theme() -> Result<(), String> {.map_err(|e| e.to_string())?;crate::output::gutter(format_bash_with_gutter("eval \"$(wt config shell init bash)\"",- "",)).map_err(|e| e.to_string())?;diff --git a/src/commands/for_each.rs b/src/commands/for_each.rsindex 00b90c502..b06f6ab4f 100644--- a/src/commands/for_each.rs+++ b/src/commands/for_each.rs@@ -102,7 +102,7 @@ pub fn step_for_each(args: Vec<String>) -> anyhow::Result<()> {output::print(error_message(cformat!("Failed in <bold>{display_name}</> (spawn failed)")))?;- output::gutter(format_with_gutter(&err, "", None))?;+ output::gutter(format_with_gutter(&err, None))?;failed.push(display_name.to_string());}Err(CommandError::ExitCode(exit_code)) => {@@ -133,7 +133,7 @@ pub fn step_for_each(args: Vec<String>) -> anyhow::Result<()> {if total == 1 { "" } else { "s" })))?;let failed_list = failed.join("\n");- output::gutter(format_with_gutter(&failed_list, "", None))?;+ output::gutter(format_with_gutter(&failed_list, None))?;// Return silent error so main exits with code 1 without duplicate messageErr(WorktrunkError::AlreadyDisplayed { exit_code: 1 }.into())}diff --git a/src/commands/hooks.rs b/src/commands/hooks.rsindex 7a3f77e57..4950574ab 100644--- a/src/commands/hooks.rs+++ b/src/commands/hooks.rs@@ -81,7 +81,7 @@ impl<'a> HookPipeline<'a> {) -> anyhow::Result<()> {let label = crate::commands::format_command_label(label_prefix, prepared.name.as_deref());crate::output::print(progress_message(format!("{label}:")))?;- crate::output::gutter(format_bash_with_gutter(&prepared.expanded, ""))?;+ crate::output::gutter(format_bash_with_gutter(&prepared.expanded))?;Ok(())}diff --git a/src/commands/list/collect.rs b/src/commands/list/collect.rsindex 91924e775..199aafc58 100644--- a/src/commands/list/collect.rs+++ b/src/commands/list/collect.rs@@ -1071,7 +1071,7 @@ pub fn collect(.collect();diag.push_str(&format!("\n{}",- format_with_gutter(&missing_lines.join("\n"), "", None)+ format_with_gutter(&missing_lines.join("\n"), None)));}@@ -1146,7 +1146,7 @@ pub fn collect(.collect();let warning = format!("Some git operations failed:\n{}",- format_with_gutter(&error_lines.join("\n"), "", None)+ format_with_gutter(&error_lines.join("\n"), None));crate::output::print(warning_message(warning))?;}diff --git a/src/commands/merge.rs b/src/commands/merge.rsindex d6cd46cf9..92dec79b0 100644--- a/src/commands/merge.rs+++ b/src/commands/merge.rs@@ -228,7 +228,7 @@ pub fn handle_merge(opts: MergeOptions<'_>) -> anyhow::Result<()> {if remove_effective {// STEP 1: Check for uncommitted changes before attempting cleanup// This prevents showing "Cleaning up worktree..." before failing- repo.ensure_clean_working_tree(Some("remove worktree after merge"), Some(¤t_branch))?;+ repo.ensure_clean_working_tree("remove worktree after merge", Some(¤t_branch))?;// STEP 2: Remove worktree via shared remove output handler so final message matches wt removelet worktree_root = repo.worktree_root()?.to_path_buf();diff --git a/src/commands/mod.rs b/src/commands/mod.rsindex 8d48ef22d..44104c91d 100644--- a/src/commands/mod.rs+++ b/src/commands/mod.rs@@ -84,7 +84,7 @@ pub fn show_diffstat(repo: &worktrunk::git::Repository, range: &str) -> anyhow::.to_string();if !diff_stat.is_empty() {- crate::output::gutter(format_with_gutter(&diff_stat, "", None))?;+ crate::output::gutter(format_with_gutter(&diff_stat, None))?;}Ok(())diff --git a/src/commands/repository_ext.rs b/src/commands/repository_ext.rsindex f96c7ef9b..9af029729 100644--- a/src/commands/repository_ext.rs+++ b/src/commands/repository_ext.rs@@ -122,7 +122,7 @@ impl RepositoryCliExt for Repository {}let target_repo = Repository::at(&worktree_path);- target_repo.ensure_clean_working_tree(Some("remove worktree"), Some(branch_name))?;+ target_repo.ensure_clean_working_tree("remove worktree", Some(branch_name))?;let current_worktree = self.worktree_root()?.to_path_buf();let removing_current = current_worktree == worktree_path;@@ -191,7 +191,7 @@ impl RepositoryCliExt for Repository {let branch_name = current_wt.and_then(|wt| wt.branch.clone());// Ensure the working tree is clean- self.ensure_clean_working_tree(Some("remove worktree"), branch_name.as_deref())?;+ self.ensure_clean_working_tree("remove worktree", branch_name.as_deref())?;// Get main worktree path (we're removing current, so we'll cd to main)let main_path = worktrees.main().path.clone();@@ -436,7 +436,7 @@ impl AutoStageWarning {)))?;let joined_files = self.files.join("\n");- crate::output::gutter(format_with_gutter(&joined_files, "", None))?;+ crate::output::gutter(format_with_gutter(&joined_files, None))?;Ok(())}diff --git a/src/commands/standalone.rs b/src/commands/standalone.rsindex aa8a3b9dd..64b652ee8 100644--- a/src/commands/standalone.rs+++ b/src/commands/standalone.rs@@ -367,7 +367,7 @@ pub fn handle_squash(// Create safety backup before potentially destructive reset if there are working tree changesif has_staged {let backup_message = format!("{} → {} (squash)", current_branch, target_branch);- let (sha, _restore_cmd) = repo.create_safety_backup(&backup_message)?;+ let sha = repo.create_safety_backup(&backup_message)?;crate::output::print(hint_message(format!("Backup created @ {sha}")))?;}@@ -397,7 +397,7 @@ pub fn handle_squash(// Display the generated commit messagelet formatted_message = generator.format_message_for_display(&commit_message);- crate::output::gutter(format_with_gutter(&formatted_message, "", None))?;+ crate::output::gutter(format_with_gutter(&formatted_message, None))?;// Reset to merge base (soft reset stages all changes, including any already-staged uncommitted changes)repo.run_command(&["reset", "--soft", &merge_base])@@ -882,7 +882,7 @@ fn render_hook_commands(cmd.template.clone()};- write!(out, "{}", format_bash_with_gutter(&command_text, ""))?;+ write!(out, "{}", format_bash_with_gutter(&command_text))?;}Ok(())diff --git a/src/commands/worktree.rs b/src/commands/worktree.rsindex f4b94eff9..0288829bb 100644--- a/src/commands/worktree.rs+++ b/src/commands/worktree.rs@@ -802,7 +802,7 @@ pub fn handle_remove_by_path(// Check that the worktree is cleanlet target_repo = Repository::at(path);target_repo- .ensure_clean_working_tree(Some("remove worktree"), branch.as_deref())+ .ensure_clean_working_tree("remove worktree", branch.as_deref()).context("Failed to verify worktree status")?;// We're not in this worktree, so no directory change needed@@ -1060,7 +1060,7 @@ pub fn handle_push("--oneline",&format!("{}..HEAD", target_branch),])?;- crate::output::gutter(format_with_gutter(&log_output, "", None))?;+ crate::output::gutter(format_with_gutter(&log_output, None))?;// Show diff statisticssuper::show_diffstat(&repo, &format!("{}..HEAD", target_branch))?;diff --git a/src/git/error.rs b/src/git/error.rsindex c9947662f..9a03f847e 100644--- a/src/git/error.rs+++ b/src/git/error.rs@@ -251,7 +251,7 @@ impl std::fmt::Display for GitError {"Cannot create worktree for <bold>{branch}</>: {error_detail}")),hint,- format_bash_with_gutter(&command, "")+ format_bash_with_gutter(&command))}@@ -318,7 +318,7 @@ impl std::fmt::Display for GitError {)?;if !files.is_empty() {let joined_files = files.join("\n");- write!(f, "{}", format_with_gutter(&joined_files, "", None))?;+ write!(f, "{}", format_with_gutter(&joined_files, None))?;}let path_display = format_path_for_display(worktree_path);write!(@@ -343,7 +343,7 @@ impl std::fmt::Display for GitError {)))?;if !commits_formatted.is_empty() {- write!(f, "\n{}", format_with_gutter(commits_formatted, "", None))?;+ write!(f, "\n{}", format_with_gutter(commits_formatted, None))?;}// Context-appropriate hintlet merge_cmd = suggest_command("merge", &[target_branch], &[]);@@ -389,7 +389,7 @@ impl std::fmt::Display for GitError {error_message(cformat!("Rebase onto <bold>{target_branch}</> incomplete")))?;if !git_output.is_empty() {- write!(f, "\n{}", format_with_gutter(git_output, "", None))+ write!(f, "\n{}", format_with_gutter(git_output, None))} else {write!(f,@@ -467,7 +467,7 @@ impl std::fmt::Display for GitError {let error_block = format_error_block(error_header, error);// Show full pipeline command if available, otherwise just the LLM commandlet display_command = reproduction_command.as_ref().unwrap_or(command);- let command_gutter = format_with_gutter(display_command, "", None);+ let command_gutter = format_with_gutter(display_command, None);write!(f,"{}\n\n{}\n{}",@@ -649,7 +649,7 @@ fn format_error_block(header: impl Into<String>, error: &str) -> String {if trimmed.is_empty() {header} else {- format!("{header}\n{}", format_with_gutter(trimmed, "", None))+ format!("{header}\n{}", format_with_gutter(trimmed, None))}}diff --git a/src/git/repository/mod.rs b/src/git/repository/mod.rsindex 83e2ce78a..913cf7879 100644--- a/src/git/repository/mod.rs+++ b/src/git/repository/mod.rs@@ -595,12 +595,12 @@ impl Repository {/// - `worktree` identifies which worktree (e.g., branch name) for multi-worktree operations.pub fn ensure_clean_working_tree(&self,- action: Option<&str>,+ action: &str,worktree: Option<&str>,) -> anyhow::Result<()> {if self.is_dirty()? {return Err(GitError::UncommittedChanges {- action: action.map(String::from),+ action: Some(action.into()),worktree: worktree.map(String::from),}.into());@@ -1063,18 +1063,18 @@ impl Repository {////// Users can find safety backups with: `git reflog show refs/wt-backup/<branch>`///- /// Returns the SHA of the backup commit and a restore command.+ /// Returns the short SHA of the backup commit.////// # Example/// ```no_run/// use worktrunk::git::Repository;////// let repo = Repository::current();- /// let (sha, restore_cmd) = repo.create_safety_backup("feature → main (squash)")?;- /// println!("Backup created: {} - Restore with: {}", sha, restore_cmd);+ /// let sha = repo.create_safety_backup("feature → main (squash)")?;+ /// println!("Backup created: {}", sha);/// # Ok::<(), anyhow::Error>(())/// ```- pub fn create_safety_backup(&self, message: &str) -> anyhow::Result<(String, String)> {+ pub fn create_safety_backup(&self, message: &str) -> anyhow::Result<String> {// Create a backup commit using git stash create (without storing it in the stash list)let backup_sha = self.run_command(&["stash", "create", "--include-untracked"])?@@ -1112,12 +1112,7 @@ impl Repository {]).context("Failed to create backup ref")?;- // Return short SHA and restore command- // Use git stash apply because the backup is a merge commit (created by git stash create)- let short_sha = &backup_sha[..7];- let restore_cmd = format!("git stash apply --index {}", short_sha);-- Ok((short_sha.to_string(), restore_cmd))+ Ok(backup_sha[..7].to_string())}/// Get all branch names (local branches only).diff --git a/src/main.rs b/src/main.rsindex 6b88bd7db..cd1f95a63 100644--- a/src/main.rs+++ b/src/main.rs@@ -1588,7 +1588,7 @@ fn main() {// Has context: msg is context, chain contains intermediate + root causelet _ = output::print(error_message(&msg));let chain_text = chain.join("\n");- let _ = output::gutter(format_with_gutter(&chain_text, "", None));+ let _ = output::gutter(format_with_gutter(&chain_text, None));} else if msg.contains('\n') {// Multiline error without context - this shouldn't happen if all// errors have proper context. Fail in tests, log in production.@@ -1597,7 +1597,7 @@ fn main() {}log::warn!("Multiline error without context: {msg}");let _ = output::print(error_message("Command failed"));- let _ = output::gutter(format_with_gutter(&msg, "", None));+ let _ = output::gutter(format_with_gutter(&msg, None));} else {// Single-line error without context: inline with emojilet _ = output::print(error_message(&msg));diff --git a/src/output/handlers.rs b/src/output/handlers.rsindex 086a6b8cc..8f0f4e7b1 100644--- a/src/output/handlers.rs+++ b/src/output/handlers.rs@@ -186,7 +186,7 @@ fn handle_branch_deletion_result(super::print(error_message(cformat!("Failed to delete branch <bold>{branch_name}</>")))?;- super::gutter(format_with_gutter(&e.to_string(), "", None))?;+ super::gutter(format_with_gutter(&e.to_string(), None))?;Err(e)}}@@ -448,7 +448,7 @@ pub fn execute_user_command(command: &str) -> anyhow::Result<()> {// Show what command is being executed (section header + gutter content)super::print(progress_message("Executing (--execute):"))?;- super::gutter(format_bash_with_gutter(command, ""))?;+ super::gutter(format_bash_with_gutter(command))?;super::execute(command)?;diff --git a/src/styling/format.rs b/src/styling/format.rsindex 3cb7d5690..5754a036e 100644--- a/src/styling/format.rs+++ b/src/styling/format.rs@@ -2,8 +2,6 @@//!//! Provides functions for formatting commands and configuration with visual gutters.-use unicode_width::UnicodeWidthStr;-#[cfg(feature = "syntax-highlighting")]use super::highlighting::bash_token_style;@@ -99,7 +97,6 @@ pub(super) fn wrap_text_at_width(text: &str, max_width: usize) -> Vec<String> {////// # Arguments/// * `content` - The text to format (preserves internal structure for multi-line)-/// * `left_margin` - Should always be "" (gutter provides all visual separation)/// * `max_width` - Optional maximum width (for testing). If None, auto-detects terminal width.////// The gutter appears at column 0, followed by 1 space, then the content starts at column 2.@@ -109,27 +106,24 @@ pub(super) fn wrap_text_at_width(text: &str, max_width: usize) -> Vec<String> {/// ```/// use worktrunk::styling::format_with_gutter;///-/// print!("{}", format_with_gutter("hello world", "", Some(80)));+/// print!("{}", format_with_gutter("hello world", Some(80)));/// ```-pub fn format_with_gutter(content: &str, left_margin: &str, max_width: Option<usize>) -> String {+pub fn format_with_gutter(content: &str, max_width: Option<usize>) -> String {let gutter = super::GUTTER;let mut output = String::new();// Use provided width or detect terminal width (respects COLUMNS env var)let term_width = max_width.unwrap_or_else(get_terminal_width);- // Account for gutter (1) + space (1) + left_margin- let left_margin_width = left_margin.width();- let available_width = term_width.saturating_sub(2 + left_margin_width);+ // Account for gutter (1) + space (1)+ let available_width = term_width.saturating_sub(2);for line in content.lines() {// Wrap the line at word boundarieslet wrapped_lines = wrap_text_at_width(line, available_width);for wrapped_line in wrapped_lines {- output.push_str(&format!(- "{left_margin}{gutter} {gutter:#} {wrapped_line}\n"- ));+ output.push_str(&format!("{gutter} {gutter:#} {wrapped_line}\n"));}}@@ -184,11 +178,7 @@ pub fn wrap_styled_text(styled: &str, max_width: usize) -> Vec<String> {}#[cfg(feature = "syntax-highlighting")]-fn format_bash_with_gutter_impl(- content: &str,- left_margin: &str,- width_override: Option<usize>,-) -> String {+fn format_bash_with_gutter_impl(content: &str, width_override: Option<usize>) -> String {use tree_sitter_highlight::{HighlightConfiguration, HighlightEvent, Highlighter};let gutter = super::GUTTER;@@ -198,8 +188,7 @@ fn format_bash_with_gutter_impl(// Calculate available width for contentlet term_width = width_override.unwrap_or_else(get_terminal_width);- let left_margin_width = left_margin.width();- let available_width = term_width.saturating_sub(2 + left_margin_width);+ let available_width = term_width.saturating_sub(2);// Set up tree-sitter bash highlightinglet highlight_names = vec![@@ -251,9 +240,7 @@ fn format_bash_with_gutter_impl(// Fallback: if highlighting fails, use plain dimstyled_line.push_str(line);for wrapped in wrap_styled_text(&styled_line, available_width) {- output.push_str(&format!(- "{left_margin}{gutter} {gutter:#} {wrapped}{reset}\n"- ));+ output.push_str(&format!("{gutter} {gutter:#} {wrapped}{reset}\n"));}continue;};@@ -306,9 +293,7 @@ fn format_bash_with_gutter_impl(// Wrap and output with gutterfor wrapped in wrap_styled_text(&styled_line, available_width) {- output.push_str(&format!(- "{left_margin}{gutter} {gutter:#} {wrapped}{reset}\n"- ));+ output.push_str(&format!("{gutter} {gutter:#} {wrapped}{reset}\n"));}}@@ -325,23 +310,19 @@ fn format_bash_with_gutter_impl(/// ```/// use worktrunk::styling::format_bash_with_gutter;///-/// print!("{}", format_bash_with_gutter("npm install --frozen-lockfile", ""));+/// print!("{}", format_bash_with_gutter("npm install --frozen-lockfile"));/// ```#[cfg(feature = "syntax-highlighting")]-pub fn format_bash_with_gutter(content: &str, left_margin: &str) -> String {- format_bash_with_gutter_impl(content, left_margin, None)+pub fn format_bash_with_gutter(content: &str) -> String {+ format_bash_with_gutter_impl(content, None)}/// Test-only helper to force a specific terminal width for deterministic output.////// This avoids env var mutation which is unsafe in parallel tests.#[cfg(all(test, feature = "syntax-highlighting"))]-pub(crate) fn format_bash_with_gutter_at_width(- content: &str,- left_margin: &str,- width: usize,-) -> String {- format_bash_with_gutter_impl(content, left_margin, Some(width))+pub(crate) fn format_bash_with_gutter_at_width(content: &str, width: usize) -> String {+ format_bash_with_gutter_impl(content, Some(width))}/// Format bash commands with gutter (fallback without syntax highlighting)@@ -349,8 +330,8 @@ pub(crate) fn format_bash_with_gutter_at_width(/// This version is used when the `syntax-highlighting` feature is disabled./// It provides the same gutter formatting without tree-sitter dependencies.#[cfg(not(feature = "syntax-highlighting"))]-pub fn format_bash_with_gutter(content: &str, left_margin: &str) -> String {- format_with_gutter(content, left_margin, None)+pub fn format_bash_with_gutter(content: &str) -> String {+ format_with_gutter(content, None)}#[cfg(test)]@@ -421,7 +402,7 @@ mod tests {#[test]fn test_format_with_gutter_basic() {- let result = format_with_gutter("hello", "", Some(80));+ let result = format_with_gutter("hello", Some(80));// Should have gutter formattingassert!(result.contains("hello"));assert!(result.ends_with('\n'));@@ -429,7 +410,7 @@ mod tests {#[test]fn test_format_with_gutter_multiline() {- let result = format_with_gutter("line1\nline2", "", Some(80));+ let result = format_with_gutter("line1\nline2", Some(80));// Each line should be formatted separatelyassert!(result.contains("line1"));assert!(result.contains("line2"));@@ -445,24 +426,15 @@ mod tests {#[test]fn test_format_with_gutter_empty() {- let result = format_with_gutter("", "", Some(80));+ let result = format_with_gutter("", Some(80));// Empty input should produce empty outputassert!(result.is_empty());}- #[test]- fn test_format_with_gutter_with_margin() {- let result = format_with_gutter("content", " ", Some(80));- // Content with margin should still have the content- assert!(result.contains("content"));- // Should start with margin spaces- assert!(result.starts_with(" "));- }-#[test]fn test_format_with_gutter_wrapping() {// Use a very narrow width to force wrapping- let result = format_with_gutter("word1 word2 word3 word4", "", Some(15));+ let result = format_with_gutter("word1 word2 word3 word4", Some(15));// Content should be wrapped to multiple lineslet line_count = result.matches('\n').count();assert!(@@ -507,7 +479,7 @@ mod tests {#[test]#[cfg(feature = "syntax-highlighting")]fn test_format_bash_with_gutter_at_width_basic() {- let result = format_bash_with_gutter_at_width("echo hello", "", 80);+ let result = format_bash_with_gutter_at_width("echo hello", 80);assert!(result.contains("echo"));assert!(result.contains("hello"));assert!(result.ends_with('\n'));@@ -516,7 +488,7 @@ mod tests {#[test]#[cfg(feature = "syntax-highlighting")]fn test_format_bash_with_gutter_at_width_multiline() {- let result = format_bash_with_gutter_at_width("echo line1\necho line2", "", 80);+ let result = format_bash_with_gutter_at_width("echo line1\necho line2", 80);assert!(result.contains("line1"));assert!(result.contains("line2"));// Two lines should have two newlines@@ -526,8 +498,7 @@ mod tests {#[test]#[cfg(feature = "syntax-highlighting")]fn test_format_bash_with_gutter_complex_command() {- let result =- format_bash_with_gutter_at_width("npm install && cargo build --release", "", 100);+ let result = format_bash_with_gutter_at_width("npm install && cargo build --release", 100);assert!(result.contains("npm"));assert!(result.contains("cargo"));assert!(result.contains("--release"));diff --git a/src/styling/highlighting.rs b/src/styling/highlighting.rsindex 5b0be95f5..b6868e938 100644--- a/src/styling/highlighting.rs+++ b/src/styling/highlighting.rs@@ -87,7 +87,7 @@ pub(super) fn bash_token_style(kind: &str) -> Option<Style> {// ============================================================================/// Formats TOML content with syntax highlighting using synoptic-pub fn format_toml(content: &str, left_margin: &str) -> String {+pub fn format_toml(content: &str) -> String {let gutter = super::GUTTER;// Get TOML highlighter from synoptic's built-in rules (tab_width = 4)@@ -98,9 +98,7 @@ pub fn format_toml(content: &str, left_margin: &str) -> String {let dim = Style::new().dimmed();let mut output = String::new();for line in content.lines() {- output.push_str(&format!(- "{left_margin}{gutter} {gutter:#} {dim}{line}{dim:#}\n"- ));+ output.push_str(&format!("{gutter} {gutter:#} {dim}{line}{dim:#}\n"));}return output;}@@ -114,8 +112,8 @@ pub fn format_toml(content: &str, left_margin: &str) -> String {// Render each line with appropriate stylingfor (y, line) in lines.iter().enumerate() {- // Add left margin, gutter, and spacing- output.push_str(&format!("{left_margin}{gutter} {gutter:#} "));+ // Add gutter and spacing+ output.push_str(&format!("{gutter} {gutter:#} "));// Render each token with appropriate stylingfor token in highlighter.line(y, line) {@@ -308,7 +306,7 @@ mod tests {#[test]fn test_format_toml_basic() {let content = "[section]\nkey = \"value\"";- let result = format_toml(content, "");+ let result = format_toml(content);// Should contain the original content (highlighted or not)assert!(result.contains("section"));assert!(result.contains("key"));@@ -317,20 +315,10 @@ mod tests {assert!(result.lines().count() >= 2);}- #[test]- fn test_format_toml_with_margin() {- let content = "key = true";- let result = format_toml(content, " ");- // Should have margin prefix- assert!(result.starts_with(" "));- assert!(result.contains("key"));- assert!(result.contains("true"));- }-#[test]fn test_format_toml_multiline() {let content = "[table]\nkey1 = \"value1\"\nkey2 = 42\n# comment\nkey3 = false";- let result = format_toml(content, "");+ let result = format_toml(content);// Each line should be presentassert!(result.contains("table"));assert!(result.contains("key1"));@@ -342,7 +330,7 @@ mod tests {#[test]fn test_format_toml_empty() {let content = "";- let result = format_toml(content, "");+ let result = format_toml(content);// Empty content should produce empty output (or just newlines)assert!(result.is_empty() || result.trim().is_empty() || result == "\n");}diff --git a/src/styling/mod.rs b/src/styling/mod.rsindex aa38a65d4..9ea3ab4d0 100644--- a/src/styling/mod.rs+++ b/src/styling/mod.rs@@ -106,7 +106,7 @@ project = "github.com/user/repo"command = "npm install""#;- let output = format_toml(toml_content, "");+ let output = format_toml(toml_content);// Check that output contains ANSI escape codesassert!(@@ -288,7 +288,7 @@ command = "npm install"let long_text = "This is a very long commit message that would normally overflow the terminal width and break the gutter formatting, but now it should wrap nicely at word boundaries.";// Use fixed width for consistent testing (80 columns)- let result = format_with_gutter(long_text, "", Some(80));+ let result = format_with_gutter(long_text, Some(80));// Should contain multiple lines (wrapped)let line_count = result.lines().count();@@ -310,7 +310,7 @@ command = "npm install"#[test]fn test_format_with_gutter_preserves_newlines() {let multi_line = "Line 1\nLine 2\nLine 3";- let result = format_with_gutter(multi_line, "", None);+ let result = format_with_gutter(multi_line, None);// Should have at least 3 lines (one for each input line)assert!(result.lines().count() >= 3);@@ -327,7 +327,7 @@ command = "npm install"let commit_msg = "This commit refactors the authentication system to use a more secure token-based approach instead of the previous session-based system which had several security vulnerabilities that were identified during the security audit last month. The new implementation follows industry best practices and includes proper token rotation and expiration handling.";// Use fixed width for consistent testing (80 columns)- let result = format_with_gutter(commit_msg, "", Some(80));+ let result = format_with_gutter(commit_msg, Some(80));insta::assert_snapshot!(result, @r"[107m [0m This commit refactors the authentication system to use a more secure@@ -343,7 +343,7 @@ command = "npm install"// Test that bash gutter formatting properly resets colors at the end of each line// to prevent color bleeding into subsequent output (like child process output)let command = "pre-commit run --all-files";- let result = format_bash_with_gutter(command, "");+ let result = format_bash_with_gutter(command);// The output should end with ANSI reset code followed by newline// ANSI reset is \x1b[0m (ESC[0m)@@ -355,7 +355,7 @@ command = "npm install"// Verify the reset appears at the end of EVERY line (for multi-line commands)let multi_line_command = "npm install && \\\n npm run build";- let multi_result = format_bash_with_gutter(multi_line_command, "");+ let multi_result = format_bash_with_gutter(multi_line_command);// Each line should end with reset codefor line in multi_result.lines() {@@ -559,7 +559,7 @@ command = "npm install"let command = "cp -cR {{ repo_root }}/target/debug/.fingerprint {{ repo_root }}/target/debug/build {{ worktree }}/target/debug/";// Use explicit width for deterministic output (avoids env var mutation in parallel tests)- let result = format_bash_with_gutter_at_width(command, "", 80);+ let result = format_bash_with_gutter_at_width(command, 80);// Snapshot the raw output to verify ANSI codes are consistentinsta::assert_snapshot!(result);@@ -589,7 +589,7 @@ cp -cR {{ repo_root }}/target/debug/.fingerprint {{ repo_root }}/target/debug/bu}}/target/debug/"#;// Use explicit width for deterministic output (avoids env var mutation in parallel tests)- let result = format_bash_with_gutter_at_width(multiline_command, "", 80);+ let result = format_bash_with_gutter_at_width(multiline_command, 80);// Snapshot the output - each line should have consistent dim stylinginsta::assert_snapshot!(result);@@ -603,7 +603,7 @@ cp -cR {{ repo_root }}/target/debug/.fingerprint {{ repo_root }}/target/debug/bu// The template text `{{ worktree` and `}}` should have identical ANSI codes.let multiline = "echo {{ worktree\n}}/path";- let result = format_bash_with_gutter(multiline, "");+ let result = format_bash_with_gutter(multiline);let lines: Vec<&str> = result.lines().collect();assert_eq!(lines.len(), 2, "Should have 2 lines");@@ -644,7 +644,7 @@ cp -cR {{ repo_root }}/target/debug/.fingerprint {{ repo_root }}/target/debug/bu// This catches regressions where all text becomes the same color.let command = "echo 'hello' | grep hello > output.txt && cat output.txt";- let result = format_bash_with_gutter(command, "");+ let result = format_bash_with_gutter(command);// Check for presence of different ANSI color codes:// - Blue (34m) for commands like echo, grep, cat@@ -698,7 +698,7 @@ cp -c {{ repo_root }}/target/debug/deps/*.rlib {{ repo_root }}/target/debug/depscp -cR {{ repo_root }}/target/debug/.fingerprint {{ repo_root }}/target/debug/build {{ worktree}}/target/debug/"#;- let result = format_bash_with_gutter(command, "");+ let result = format_bash_with_gutter(command);// The critical assertion: NO [39m codes should appear anywhere in the output.// [39m is "reset foreground to default" - we never emit this, only [0m (full reset).@@ -744,7 +744,7 @@ cp -cR {{ repo_root }}/target/debug/.fingerprint {{ repo_root }}/target/debug/bu// The fix: token styles use dim+color only (no bold). This test ensures we// don't regress by checking that [2m][1m][2m] never appears.let command = "cp -cR path/to/source path/to/dest";- let result = format_bash_with_gutter(command, "");+ let result = format_bash_with_gutter(command);// The problematic pattern is [2m] followed by [1m] followed by [2m]// This happens when: line starts with dim, style adds bold+dim@@ -765,7 +765,7 @@ cp -cR {{ repo_root }}/target/debug/.fingerprint {{ repo_root }}/target/debug/bu//// Token styles should emit [2m] (dim) along with their color.let command = "cp -cR path/to/source path/to/dest";- let result = format_bash_with_gutter(command, "");+ let result = format_bash_with_gutter(command);// Verify commands are dim+blue: [0m][2m][34m] (reset, dim, blue)assert!(