[PR #1102] [MERGED] fix: prevent sparse spacing in hyphenated words #9812

Closed
opened 2026-02-16 18:14:12 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/anomalyco/opencode/pull/1102
Author: @monotykamary
Created: 7/17/2025
Status: Merged
Merged: 7/19/2025
Merged by: @adamdotdevin

Base: devHead: fix/hyphen-word-wrapping


📝 Commits (4)

  • d4e3ca1 fix: prevent sparse spacing in hyphenated words
  • ac501a1 fix: add missing u's
  • ba75495 Merge branch 'dev' into fix/hyphen-word-wrapping
  • cf646e5 refactor: make hyphen handling ergonomic and dynamic

📊 Changes

4 files changed (+70 additions, -7 deletions)

View changed files

📝 packages/tui/internal/components/chat/message.go (+10 -4)
📝 packages/tui/internal/components/textarea/textarea.go (+4 -0)
📝 packages/tui/internal/util/file.go (+9 -3)
packages/tui/internal/util/text.go (+47 -0)

📄 Description

Summary

This PR fixes the sparse spacing issue that occurs when displaying hyphenated words like 'claude-code-action' in both Assistant and User messages in the TUI. Fixes #621.

Problem

Previously, hyphenated words would break at hyphens, creating sparse single-word lines that made the chat interface look broken and difficult to read.

Before:
image

Solution

After:
image

  • Assistant messages: Use non-breaking hyphens (U+2011) in markdown rendering to prevent word breaks at hyphens
  • User messages: Apply non-breaking hyphens before word wrapping and styling
  • Textarea component: Modified word boundary detection to treat hyphens as part of words
  • Width constraint: Maintained 86 character width limit with precise calculations

Changes Made

  1. packages/tui/internal/components/chat/message.go: Updated user message rendering to use non-breaking hyphens
  2. packages/tui/internal/components/textarea/textarea.go: Modified word boundary detection in textarea word wrapping
  3. packages/tui/internal/util/file.go: Enhanced markdown rendering with hyphen handling

Testing

  • Verified both Assistant and User messages display correctly
  • Confirmed 86 character width constraint is maintained
  • Tested with various hyphenated words and phrases
  • No visual regressions in existing functionality

This change significantly improves the readability of hyphenated content in the TUI without affecting any other functionality.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/anomalyco/opencode/pull/1102 **Author:** [@monotykamary](https://github.com/monotykamary) **Created:** 7/17/2025 **Status:** ✅ Merged **Merged:** 7/19/2025 **Merged by:** [@adamdotdevin](https://github.com/adamdotdevin) **Base:** `dev` ← **Head:** `fix/hyphen-word-wrapping` --- ### 📝 Commits (4) - [`d4e3ca1`](https://github.com/anomalyco/opencode/commit/d4e3ca1683f4615f5d3e8b38d746d1314d81a0fa) fix: prevent sparse spacing in hyphenated words - [`ac501a1`](https://github.com/anomalyco/opencode/commit/ac501a1a1493909a9e3c1a42c7c75f671e03d702) fix: add missing u's - [`ba75495`](https://github.com/anomalyco/opencode/commit/ba75495b0d4345e29cebfabc6ca75773d742242d) Merge branch 'dev' into fix/hyphen-word-wrapping - [`cf646e5`](https://github.com/anomalyco/opencode/commit/cf646e598eb8b97026c8fab453739f6a229fc0e0) refactor: make hyphen handling ergonomic and dynamic ### 📊 Changes **4 files changed** (+70 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `packages/tui/internal/components/chat/message.go` (+10 -4) 📝 `packages/tui/internal/components/textarea/textarea.go` (+4 -0) 📝 `packages/tui/internal/util/file.go` (+9 -3) ➕ `packages/tui/internal/util/text.go` (+47 -0) </details> ### 📄 Description ## Summary This PR fixes the sparse spacing issue that occurs when displaying hyphenated words like 'claude-code-action' in both Assistant and User messages in the TUI. Fixes #621. ## Problem Previously, hyphenated words would break at hyphens, creating sparse single-word lines that made the chat interface look broken and difficult to read. Before: <img width="704" height="651" alt="image" src="https://github.com/user-attachments/assets/0aaf5435-5a2b-4ac3-9e2e-a47df65ba872" /> ## Solution After: <img width="703" height="651" alt="image" src="https://github.com/user-attachments/assets/00cc4ae0-dbaa-40cb-a376-7f239987b626" /> - **Assistant messages**: Use non-breaking hyphens (U+2011) in markdown rendering to prevent word breaks at hyphens - **User messages**: Apply non-breaking hyphens before word wrapping and styling - **Textarea component**: Modified word boundary detection to treat hyphens as part of words - **Width constraint**: Maintained 86 character width limit with precise calculations ## Changes Made 1. **packages/tui/internal/components/chat/message.go**: Updated user message rendering to use non-breaking hyphens 2. **packages/tui/internal/components/textarea/textarea.go**: Modified word boundary detection in textarea word wrapping 3. **packages/tui/internal/util/file.go**: Enhanced markdown rendering with hyphen handling ## Testing - Verified both Assistant and User messages display correctly - Confirmed 86 character width constraint is maintained - Tested with various hyphenated words and phrases - No visual regressions in existing functionality This change significantly improves the readability of hyphenated content in the TUI without affecting any other functionality. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-16 18:14:12 -05:00
yindo closed this issue 2026-02-16 18:14:12 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#9812