fix: dedent residual whitespace after box-char removal#22
fix: dedent residual whitespace after box-char removal#22kevin-hillman wants to merge 3 commits intosteipete:mainfrom
Conversation
After stripping leading box-drawing characters (│), the padding spaces between the box char and the actual text content remained. This adds a dedent step that finds the minimum common leading whitespace across all non-empty lines and strips it, preserving relative indentation. Fixes the case where tools like Claude Code render output with │ Text (box char + 2 spaces + text), leaving 1-2 residual spaces after box-char removal. Closes steipete#10
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9a3c3d01e3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Sources/TrimmyCore/TextCleaner.swift
Outdated
| result = dedentLines.map { line in | ||
| guard !line.trimmingCharacters(in: .whitespaces).isEmpty else { | ||
| return "" | ||
| } | ||
| return String(line.dropFirst(minIndent)) |
There was a problem hiding this comment.
Limit dedent to lines that had a stripped gutter
The new dedent pass removes minIndent from every non-empty line whenever stripLeading is enabled, including lines that never matched the leading box-gutter pattern. In mixed content (for example, mostly │ ... lines plus a plain line that intentionally begins with one space), this now strips legitimate indentation from that plain line and changes user text beyond box-character cleanup. This behavior is a regression from the previous implementation, which only removed gutter characters and left unrelated line indentation intact.
Useful? React with 👍 / 👎.
Alle 70+ user-facing Strings in 10 Dateien auf Deutsch übersetzt: - Einstellungen (Allgemein, Erweitert, Aggressivität, Kurzbefehle, Über) - Menü-Einträge (Einfügen, Auto-Trim, Einstellungen) - Bedienungshilfen-Dialog - Aggressivitätsstufen und Beschreibungen
Address review feedback: the dedent pass now only considers and modifies lines where a leading box-drawing pattern was actually matched. Plain lines without box chars keep their original indentation intact, even when they appear alongside majority box-char lines. Adds a test for mixed content (box-char lines + plain indented line).
Summary
│), the padding spaces between the box char and the text remained (e.g.│ Text→Textinstead ofText)Context
Using Claude Code with cmux (tmux-based multiplexer) in iTerm, the output is rendered with
│ Text(box char + 2 padding spaces). Trimmy's box-char removal stripped the│and 1 space, but left 1-2 residual leading spaces on every line.See #10 and my comment.
Test plan
│ Text)