Skip to content

HTML preview: clicking a wrapped .html path in the terminal opens the wrong path (os error 3) #7

@astetic-dev

Description

@astetic-dev

Summary

Clicking a clickable .html path in the terminal can open the wrong path, and the HTML preview then shows "The system cannot find the path specified. (os error 3)". This happens when the printed absolute path is long enough to wrap across two terminal rows in the (narrow) split preview layout.

Steps to reproduce

  1. Have an agent print a long absolute path, e.g. C:\Users\AST\claude\projecten\_index\dashboard.html.
  2. Use the split HTML-preview layout so the terminal pane is narrow and the path wraps onto a second row.
  3. Click the path in the terminal.
  4. The preview shows ... (os error 3) instead of the file. The file itself is fine (opens normally in a browser).

Root cause

The terminal link provider in src/main.js (spawnTerminalregisterLinkProvider) inspects one buffer row at a time:

const ln = term.buffer.active.getLine(y - 1);
const text = ln.translateToString(true);
const re = /([A-Za-z]:\[^\s"'<>|]+?\.html?|[\w.\-\/]+\.html?)/gi;

When a path wraps, the matcher only sees the tail fragment on the second row (e.g. dex\dashboard.html). That fragment matches the relative-path alternative, so openPreviewFile() treats it as relative and prepends the working folder, producing a path that does not exist → read_file fails with os error 3.

Proposed fix

Reconstruct the full logical line before matching:

  • From the queried row, walk up while IBufferLine.isWrapped to find the first row, then collect following wrapped rows.
  • Concatenate the rows (column-aligned) into the full logical text and run the regex on that.
  • Map each match's character offsets back to (x, y) cell ranges; for the queried row, return the link segment(s) that fall on it, all with activate opening the full matched path.

This makes clicking any part of a wrapped path open the correct, complete path.

Acceptance criteria

  • Clicking a wrapped absolute .html path opens the correct file in the preview (no os error 3).
  • Non-wrapped paths and relative paths still work as before.
  • Clicking any row a wrapped path spans opens the same full path.

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