Skip to content

fix: replace newlines with spaces in Inline mode#633

Open
alexchenai wants to merge 1 commit intocharmbracelet:mainfrom
alexchenai:fix/inline-newline-space
Open

fix: replace newlines with spaces in Inline mode#633
alexchenai wants to merge 1 commit intocharmbracelet:mainfrom
alexchenai:fix/inline-newline-space

Conversation

@alexchenai
Copy link
Copy Markdown

Summary

  • Fixes Inline concatenates words from multiple lines #116: Inline(true) now replaces newlines with spaces instead of stripping them entirely
  • style.Render("hello\nworld") with Inline(true) now produces "hello world" instead of "helloworld"
  • Adds a test to verify the correct behavior

Details

The single-character change in style.go line 404 replaces "" with " " in the newline replacement, preserving word boundaries when rendering inline text. This matches the expected behavior described in the issue — newlines should become spaces, not disappear.

Test plan

  • All existing tests pass (go test ./...)
  • New TestInlineReplacesNewlinesWithSpaces test added and passing
  • Manual verification: NewStyle().Inline(true).Render("hello\nworld") returns "hello world"

🤖 Generated with Claude Code

…them

When Inline(true) is set, newlines were stripped entirely, causing
"hello\nworld" to render as "helloworld". This changes the behavior to
replace newlines with spaces, producing "hello world" instead, which
preserves word boundaries as expected.

Fixes charmbracelet#116

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

Inline concatenates words from multiple lines

1 participant