Skip to content

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

Add gutter to TOML config output

Maximilian Roos7efe417fd549
diff --git a/src/commands/config.rs b/src/commands/config.rs
index 2b26e932b..debd105f3 100644
--- a/src/commands/config.rs
+++ b/src/commands/config.rs
@@ -92,7 +92,7 @@ fn display_global_config() -> Result<(), GitError> {
}
// Display TOML with syntax highlighting
- print!("{}", format_toml(&contents, " "));
+ print!("{}", format_toml(&contents, " "));
Ok(())
}
@@ -130,7 +130,7 @@ fn display_project_config() -> Result<(), GitError> {
}
// Display TOML with syntax highlighting
- print!("{}", format_toml(&contents, " "));
+ print!("{}", format_toml(&contents, " "));
Ok(())
}
diff --git a/src/styling.rs b/src/styling.rs
index a05ed6a14..00b12fc5e 100644
--- a/src/styling.rs
+++ b/src/styling.rs
@@ -165,6 +165,9 @@ impl StyledLine {
/// Formats TOML content with syntax highlighting using synoptic
pub fn format_toml(content: &str, indent: &str) -> String {
+ // Gutter style: subtle background for visual separation
+ let gutter = Style::new().bg_color(Some(Color::Ansi(AnsiColor::Black)));
+
// Get TOML highlighter from synoptic's built-in rules (tab_width = 4)
let mut highlighter = match from_extension("toml", 4) {
Some(h) => h,
@@ -173,7 +176,7 @@ pub fn format_toml(content: &str, indent: &str) -> String {
let dim = Style::new().dimmed();
let mut output = String::new();
for line in content.lines() {
- output.push_str(&format!("{indent}{dim}{line}{dim:#}\n"));
+ output.push_str(&format!("{gutter} {gutter:#}{indent}{dim}{line}{dim:#}\n"));
}
return output;
}
@@ -187,7 +190,9 @@ pub fn format_toml(content: &str, indent: &str) -> String {
// Render each line with appropriate styling
for (y, line) in lines.iter().enumerate() {
- // Add indentation first
+ // Add gutter first
+ output.push_str(&format!("{gutter} {gutter:#}"));
+ // Add indentation
output.push_str(indent);
// Render each token with appropriate styling
@@ -265,7 +270,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 codes
assert!(
@@ -291,12 +296,16 @@ command = "npm install"
"Should contain cyan or bold for tables"
);
- // Check indentation is preserved
+ // Check that gutter background is present (Black background = 40)
+ assert!(
+ output.contains("\x1b[40m"),
+ "Should contain gutter background color (Black = 40)"
+ );
+
+ // Check that lines have content (not just gutter)
assert!(
- output
- .lines()
- .all(|line| line.starts_with(" ") || line.is_empty()),
- "All lines should be indented"
+ output.lines().any(|line| line.len() > 20),
+ "Should have lines with actual content beyond gutter and indent"
);
}
diff --git a/tests/snapshots/integration__integration_tests__config_list__config_list_no_project.snap b/tests/snapshots/integration__integration_tests__config_list__config_list_no_project.snap
index 3fd967f59..c568bffb7 100644
--- a/tests/snapshots/integration__integration_tests__config_list__config_list_no_project.snap
+++ b/tests/snapshots/integration__integration_tests__config_list__config_list_no_project.snap
@@ -12,7 +12,7 @@ info:
GIT_CONFIG_GLOBAL: /dev/null
GIT_CONFIG_SYSTEM: /dev/null
GIT_EDITOR: ""
- HOME: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpOhSuMo
+ HOME: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpJLGPUB
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1704067200"
@@ -21,7 +21,7 @@ success: true
exit_code: 0
----- stdout -----
Global Config: [TEMP_HOME]/.config/worktrunk/config.toml
- worktree-path = "../{main-worktree}.{branch}"
+  worktree-path = "../{main-worktree}.{branch}"
Project Config: [REPO]/.config/wt.toml
💡 Not found
diff --git a/tests/snapshots/integration__integration_tests__config_list__config_list_outside_repo.snap b/tests/snapshots/integration__integration_tests__config_list__config_list_outside_repo.snap
index aabadacc2..e8e934286 100644
--- a/tests/snapshots/integration__integration_tests__config_list__config_list_outside_repo.snap
+++ b/tests/snapshots/integration__integration_tests__config_list__config_list_outside_repo.snap
@@ -6,7 +6,7 @@ info:
- config
- list
env:
- HOME: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpxHds55
+ HOME: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpfgWomq
---
success: true
exit_code: 0
diff --git a/tests/snapshots/integration__integration_tests__config_list__config_list_with_project.snap b/tests/snapshots/integration__integration_tests__config_list__config_list_with_project.snap
index d348b0915..d94fbf043 100644
--- a/tests/snapshots/integration__integration_tests__config_list__config_list_with_project.snap
+++ b/tests/snapshots/integration__integration_tests__config_list__config_list_with_project.snap
@@ -12,7 +12,7 @@ info:
GIT_CONFIG_GLOBAL: /dev/null
GIT_CONFIG_SYSTEM: /dev/null
GIT_EDITOR: ""
- HOME: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmp8ZWNvA
+ HOME: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpcA2FvP
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1704067200"
@@ -21,16 +21,16 @@ success: true
exit_code: 0
----- stdout -----
Global Config: [TEMP_HOME]/.config/worktrunk/config.toml
- worktree-path = "../{main-worktree}.{branch}"
-
- [[approved-commands]]
- project = "test-project"
- command = "npm install"
+  worktree-path = "../{main-worktree}.{branch}"
+ 
+  [[approved-commands]]
+  project = "test-project"
+  command = "npm install"
Project Config: [REPO]/.config/wt.toml
- post-create-command = "npm install"
-
- [post-start-command]
- server = "npm run dev"
+  post-create-command = "npm install"
+ 
+  [post-start-command]
+  server = "npm run dev"
----- stderr -----