Skip to content

OSC 8 hyperlink navigation commands stop on the same OSC 8 hyperlink multiple times #125

@lucasec

Description

@lucasec

Continuing from #85 (comment)

jFYI, I implemented ghostel-next/previous-hyperlink (C-c C-p/n) and also some eshell integration for eshell-visual-commands.

Testing out you C-c C-p/C-n bindings, I used the test file here: https://gitlab.gnome.org/GNOME/vte/raw/master/perf/hyperlink-demo.txt
If you just cat that out in your shell, you'll see these lines at the end:

Screenshot from an imaginary text editor:
╔═ file1 ════╗
║          ╔═ file2 ═══╗
║http://exa║Lorem ipsum║
║le.com    ║ dolor sit ║
║          ║amet, conse║
╚══════════║ctetur adip║
           ╚═══════════╝

Your commands stop on both the le.com line, and the http://exa line. If you look at my implementation, you'll see I went to some lengths to make them stop only once on each unique link (as determined by the id property emitted in the OSC 8 protocol).

Cursor movement within the same OSC 8 run: move   right

is also a tricky case. The test file dosen't use the ID property for this one. But all the text lies within a single OSC 8 begin/end run. Emacs native hyperlink support treats pretty much anything other than a line break as breaking up the hyperlink, leading to this discrepancy. In my Eat implementation, I solved this by adding a monotonically increasing ID text property that increments on every OSC 8 begin sequence.

In real Ghostty, if you hold down Cmd and mouse over "move", you'll also see "right" underlined at the same time. I don't know of any way to accomplish this in Emacs without core changes or resorting to extreme hacks, so I drew the line there. But for the keyboard navigation commands it's a little easier if you want to stay true to the spec.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions