Skip to content

Preserve line metadata during reflow - #103

Merged
JohnCampionJr merged 3 commits into
tomlm:mainfrom
JohnCampionJr:codex/issue-95-reflow-metadata
Aug 29, 2026
Merged

JohnCampionJr merged 3 commits into
tomlm:mainfrom
JohnCampionJr:codex/issue-95-reflow-metadata

Conversation

@JohnCampionJr

Copy link
Copy Markdown
Collaborator

Fixes #95

Preserves OSC 8 hyperlink spans and shell-integration marks when wrapped cells are redistributed during terminal resize. Hyperlinks are split at new wrap boundaries, marks retain their logical text position, and metadata is removed from rows that no longer own the corresponding cells.

Adds regression coverage for shrink and grow reflow.

Tests: dotnet test src/XTerm.NET.Tests/XTerm.NET.Tests.csproj --no-restore (1902 passed)

@JohnCampionJr
JohnCampionJr force-pushed the codex/issue-95-reflow-metadata branch from 0052728 to eed3518 Compare August 29, 2026 17:26

@JohnCampionJr JohnCampionJr left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed against a clean worktree; built and ran the suite (1911 passed) and reproduced the one bug below.

Hot path: clear. This is resize-only. CaptureMetadata returns null when a group carries no marks or links, and the extra ReflowSmallerGetNewLineLengths call is guarded on that, so a group without metadata pays one extra null return. Nothing in the write path changes and AddLink is only reached from reflow.

One real bug: merging a wrapped link leaves it permanently fragmented. Details inline on AddLink.

Also merges cleanly with #104 (different regions of TerminalBuffer.cs); merged tree is green at 1916.

Comment thread src/XTerm.NET/Buffer/BufferLine.cs
Comment thread src/XTerm.NET/Buffer/BufferReflow.cs
Comment thread src/XTerm.NET/Buffer/BufferReflow.cs
Comment thread src/XTerm.NET/Buffer/BufferReflow.cs
Comment thread src/XTerm.NET/Buffer/BufferReflow.cs
@JohnCampionJr
JohnCampionJr requested a lite review from Copilot August 29, 2026 18:30
@JohnCampionJr
JohnCampionJr force-pushed the codex/issue-95-reflow-metadata branch from eed3518 to 48c5332 Compare August 29, 2026 18:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The logic appears consistent with the existing reflow coordinate model and is backed by targeted regression tests; only a minor documentation nit was found.

Pull request overview

This PR fixes resize reflow losing per-line metadata by capturing hyperlink spans (OSC 8) and shell-integration marks into a logical offset space before cells are redistributed, then restoring/splitting that metadata onto the rows/columns that now own the text after reflow.

Changes:

  • Capture and restore OSC 8 hyperlink spans and shell-integration marks during reflow (shrink and grow).
  • Add a low-level BufferLine.AddLink helper to rehydrate normalized link spans during restore.
  • Add regression tests ensuring marks/links migrate correctly and old phantom spans are removed.
File summaries
File Description
src/XTerm.NET/Buffer/TerminalBuffer.cs Captures/restores metadata around the reflow-smaller redistribution loop.
src/XTerm.NET/Buffer/BufferReflow.cs Implements logical capture/restore and splits links at new wrap boundaries; hooks restore into reflow-larger simulation.
src/XTerm.NET/Buffer/BufferLine.cs Adds AddLink to re-add normalized spans during metadata restore.
src/XTerm.NET.Tests/ShellIntegrationMarkAnchorTests.cs Adds coverage that a mark reflows to the row/column owning its logical position.
src/XTerm.NET.Tests/HyperlinkAnchorTests.cs Adds coverage that links move with text, old spans are removed, and links split at new wrap boundaries.
Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/XTerm.NET/Buffer/BufferLine.cs Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reflow does not migrate per-line metadata: OSC 8 links and shell-integration marks

2 participants