Skip to content

Hyperlink colorization broken with hyphens in terminal output #2634

Closed

Description

@madflow
  • 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

Activity

  1. madflow commented on Sep 16, 2025

    @madflow
    ContributorAuthor

    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
    
  2. thegreyfellow commented on Sep 23, 2025

    @thegreyfellow

    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.

  3. rekram1-node commented on Sep 23, 2025

    @rekram1-node
    Contributor

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

  4. madflow commented on Sep 23, 2025

    @madflow
    ContributorAuthor

    @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.

  5. tanishqkancharla commented on Oct 3, 2025

    @tanishqkancharla

    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
  6. thegreyfellow commented on Oct 3, 2025

    @thegreyfellow

    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 🚀

  7. madflow commented on Nov 2, 2025

    @madflow
    ContributorAuthor

    Fixed in 1.0.11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions