Skip to content

fix: dedent residual whitespace after box-char removal#22

Open
kevin-hillman wants to merge 3 commits intosteipete:mainfrom
kevin-hillman:fix/dedent-after-box-char-removal
Open

fix: dedent residual whitespace after box-char removal#22
kevin-hillman wants to merge 3 commits intosteipete:mainfrom
kevin-hillman:fix/dedent-after-box-char-removal

Conversation

@kevin-hillman
Copy link
Copy Markdown

Summary

  • After stripping leading box-drawing characters (), the padding spaces between the box char and the text remained (e.g. │ Text Text instead of Text)
  • Adds a dedent step that finds the minimum common leading whitespace across all non-empty lines and strips it
  • Preserves relative indentation (code blocks stay correctly indented)
  • Whitespace-only lines (blank lines with residual padding) are cleaned to empty strings

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

  • New test: dedents residual whitespace from Claude Code-style output (│ Text)
  • New test: preserves relative indentation when lines have different indent levels
  • Existing tests pass (single line, no box chars, pipe patterns)

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
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +469 to +473
result = dedentLines.map { line in
guard !line.trimmingCharacters(in: .whitespaces).isEmpty else {
return ""
}
return String(line.dropFirst(minIndent))
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant