Preserve line metadata during reflow - #103
Conversation
0052728 to
eed3518
Compare
JohnCampionJr
left a comment
There was a problem hiding this comment.
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.
eed3518 to
48c5332
Compare
There was a problem hiding this comment.
🟢 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.AddLinkhelper 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.
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)