Skip to content

fix: keep the trailing "#" in headings like "# C#" - #2

Merged
weskcode merged 1 commit into
developfrom
fix/heading-trailing-hash
Sep 2, 2026
Merged

weskcode merged 1 commit into
developfrom
fix/heading-trailing-hash

Conversation

@weskcode

@weskcode weskcode commented Sep 2, 2026

Copy link
Copy Markdown
Owner

The bug

String.parsedChecklistLine stripped heading markup with:

line.trimmingCharacters(in: CharacterSet(charactersIn: "# "))

trimmingCharacters(in:) trims both ends, so any heading ending in # lost it:

Note content Rendered as Should be
# C# C C#
# F# F F#
# C# vs F# C# vs F C# vs F#
# Shell # Shell Shell #

DisplayLine lives in Shared/Sources, so this affected the editor and the widget, on both platforms. For an app whose purpose is developer cheat sheets, C# and F# headings are ordinary content — this is a plausible first-session bug for a real user.

The fix

Strip only the leading hashes, then trim whitespace. Two regression tests added to DisplayLineTests.swift.

Verification

  • 57 tests in 5 suites pass on macOS (was 55).
  • The fixed parser was additionally compiled standalone against the four pre-existing heading/task/plain cases, confirming no behaviour change outside the bug.

Found while auditing test coverage, not by a failing test — nothing exercised a heading with a trailing #.

🤖 Generated with Claude Code

parsedChecklistLine stripped heading markup with
trimmingCharacters(in: CharacterSet(charactersIn: "# ")), which trims BOTH
ends. Any heading ending in "#" silently lost it:

  "# C#"        rendered as "C"
  "# F#"        rendered as "F"
  "# C# vs F#"  rendered as "C# vs F"

DisplayLine lives in Shared/Sources, so this hit the editor and the widget on
both platforms -- and "C#"/"F#" headings are ordinary content in a developer
cheat sheet, which is what this app is for.

Strip only the leading hashes instead, then trim whitespace. Adds two
regression tests.

Verified: 57 tests in 5 suites pass on macOS (was 55). The fixed parser was
also compiled standalone against the four pre-existing heading/task/plain
cases to confirm nothing outside the bug changed behaviour.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@weskcode
weskcode merged commit 786ae9f into develop Sep 2, 2026
2 checks passed
@weskcode
weskcode deleted the fix/heading-trailing-hash branch September 2, 2026 14:40
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