Hyperlink colorization broken with hyphens in terminal output #1737

Closed
opened 2026-02-16 17:32:23 -05:00 by yindo · 7 comments
Owner

Originally created by @madflow on GitHub (Sep 16, 2025).

Originally assigned to: @adamdotdevin on GitHub.

  • When printing an url, the colorization of the link is br0ken, when there is hyphen in the url.
  • Minor annoyance, still reporting it here ;)
Image
  • MacOs
  • Ghostty Terminal
  • ZSH
Originally created by @madflow on GitHub (Sep 16, 2025). Originally assigned to: @adamdotdevin on GitHub. * When printing an url, the colorization of the link is br0ken, when there is hyphen in the url. * Minor annoyance, still reporting it here ;) <img width="755" height="426" alt="Image" src="https://github.com/user-attachments/assets/7949c0b4-73ed-404a-bfab-839922cb22fa" /> * MacOs * Ghostty Terminal * ZSH
yindo closed this issue 2026-02-16 17:32:23 -05:00
Author
Owner

@madflow commented on GitHub (Sep 16, 2025):

Just a quick fire and forget model response. Maybe this helps...

## Problem Analysis

The issue is in packages/tui/internal/util/file.go:89-90. The current regex:

hyphenRegex := regexp.MustCompile(`-([^ \-|]|$)`)
content = hyphenRegex.ReplaceAllString(content, "\u2011$1")

This temporarily replaces hyphens with non-breaking hyphens (\u2011) to prevent line wrapping, but it interferes with URL detection during markdown rendering.

## Proposed Fix

The solution is to modify the hyphen replacement logic to exclude URLs. Here's the approach:

1. Add URL detection regex to identify URLs in the content
2. Use negative lookahead or URL-aware replacement to skip hyphens within URLs
3. Preserve the original line-breaking prevention for non-URL text
@madflow commented on GitHub (Sep 16, 2025): Just a quick fire and forget model response. Maybe this helps... ``` ## Problem Analysis The issue is in packages/tui/internal/util/file.go:89-90. The current regex: hyphenRegex := regexp.MustCompile(`-([^ \-|]|$)`) content = hyphenRegex.ReplaceAllString(content, "\u2011$1") This temporarily replaces hyphens with non-breaking hyphens (\u2011) to prevent line wrapping, but it interferes with URL detection during markdown rendering. ## Proposed Fix The solution is to modify the hyphen replacement logic to exclude URLs. Here's the approach: 1. Add URL detection regex to identify URLs in the content 2. Use negative lookahead or URL-aware replacement to skip hyphens within URLs 3. Preserve the original line-breaking prevention for non-URL text ```
Author
Owner

@thegreyfellow commented on GitHub (Sep 23, 2025):

Description:

May I add to this issue, something that I seem to be experiencing in the same context as the issue above.

I actually am in a worse (maybe) situation, I have bad urls and not only http but any protocol, opencode never prints the "//" (double slash) after the protocol for some weird reason. Here is a screenshot that explains the issue:

Image

Environement:

  • OS: Arch linux (Omarchy)
  • shell: Bash
  • terminal: Alacritty

Notes:

@madflow please tell me if you mind I can create another ticket, but I have a feeling they are both related.

@thegreyfellow commented on GitHub (Sep 23, 2025): ### Description: May I add to this issue, something that I seem to be experiencing in the same context as the issue above. I actually am in a worse (maybe) situation, I have bad urls and not only http but any protocol, **opencode never prints the "//" (double slash) after the protocol** for some weird reason. Here is a screenshot that explains the issue: <img width="428" height="762" alt="Image" src="https://github.com/user-attachments/assets/d7fa6846-9d4e-4050-90ec-c88746549d29" /> ### Environement: - OS: Arch linux (Omarchy) - shell: Bash - terminal: Alacritty ### Notes: @madflow please tell me if you mind I can create another ticket, but I have a feeling they are both related.
Author
Owner

@rekram1-node commented on GitHub (Sep 23, 2025):

Dax is currently migrating opencode to use opentui and I think some problems like this will be resolved by it

@rekram1-node commented on GitHub (Sep 23, 2025): Dax is currently migrating opencode to use opentui and I think some problems like this will be resolved by it
Author
Owner

@madflow commented on GitHub (Sep 23, 2025):

@thegreyfellow Lets wait for the Opentui migration to be finished and do a retest then. Maybe this // is similiar not sure. I would argue if it still exists after the update, a new issue would be best.

@madflow commented on GitHub (Sep 23, 2025): @thegreyfellow Lets wait for the Opentui migration to be finished and do a retest then. Maybe this `//` is similiar not sure. I would argue if it still exists after the update, a new issue would be best.
Author
Owner

@tanishqkancharla commented on GitHub (Oct 2, 2025):

Additional Details on Root Cause

I can confirm this bug with a specific example: https://github.com/saffron-health/monorepo gets cut off at "saffron".

Root Cause Analysis

The bug is in packages/tui/internal/util/file.go:89-90:

hyphenRegex := regexp.MustCompile(`-([^ \-|]|$)`)
content = hyphenRegex.ReplaceAllString(content, "\u2011$1")

Bug flow:

  1. Content contains URL: https://github.com/saffron-health/monorepo
  2. Line 90 replaces hyphens: https://github.com/saffron\u2011health/monorepo
  3. Line 91 renders with glamour/goldmark (which doesn't recognize \u2011 in URLs)
  4. URL parsing breaks at saffron because \u2011 is not a valid URL character
  5. Line 111 converts \u2011 back to -, but too late—the URL was already parsed incorrectly

Verification

I tested goldmark directly and it parses URLs with hyphens correctly. The issue is specifically the non-breaking hyphen replacement happening before markdown rendering.

Suggested Fix

The hyphen replacement should either:

  1. Skip URLs entirely (use regex negative lookahead for URL patterns)
  2. Be moved after markdown rendering (though this may break the original line-wrapping intent)
  3. Use a URL-aware parser to preserve URLs while still preventing line breaks in other text
@tanishqkancharla commented on GitHub (Oct 2, 2025): <Sorry for the spam. My LLM used the gh cli to post on behalf of me> ## Additional Details on Root Cause I can confirm this bug with a specific example: `https://github.com/saffron-health/monorepo` gets cut off at "saffron". ### Root Cause Analysis The bug is in `packages/tui/internal/util/file.go:89-90`: ```go hyphenRegex := regexp.MustCompile(`-([^ \-|]|$)`) content = hyphenRegex.ReplaceAllString(content, "\u2011$1") ``` **Bug flow:** 1. Content contains URL: `https://github.com/saffron-health/monorepo` 2. Line 90 replaces hyphens: `https://github.com/saffron\u2011health/monorepo` 3. Line 91 renders with glamour/goldmark (which doesn't recognize `\u2011` in URLs) 4. URL parsing breaks at `saffron` because `\u2011` is not a valid URL character 5. Line 111 converts `\u2011` back to `-`, but too late—the URL was already parsed incorrectly ### Verification I tested goldmark directly and it parses URLs with hyphens correctly. The issue is specifically the non-breaking hyphen replacement happening **before** markdown rendering. ### Suggested Fix The hyphen replacement should either: 1. Skip URLs entirely (use regex negative lookahead for URL patterns) 2. Be moved after markdown rendering (though this may break the original line-wrapping intent) 3. Use a URL-aware parser to preserve URLs while still preventing line breaks in other text
Author
Owner

@thegreyfellow commented on GitHub (Oct 3, 2025):

Description:

May I add to this issue, something that I seem to be experiencing in the same context as the issue above.

I actually am in a worse (maybe) situation, I have bad urls and not only http but any protocol, opencode never prints the "//" (double slash) after the protocol for some weird reason. Here is a screenshot that explains the issue:
...

This was fixed in 0.14 , thank you guys 🚀

@thegreyfellow commented on GitHub (Oct 3, 2025): > ### Description: > May I add to this issue, something that I seem to be experiencing in the same context as the issue above. > > I actually am in a worse (maybe) situation, I have bad urls and not only http but any protocol, **opencode never prints the "//" (double slash) after the protocol** for some weird reason. Here is a screenshot that explains the issue: > ... **This was fixed in 0.14 , thank you guys 🚀**
Author
Owner

@madflow commented on GitHub (Nov 2, 2025):

Fixed in 1.0.11

@madflow commented on GitHub (Nov 2, 2025): Fixed in 1.0.11
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#1737