Skip to content

feat(buffer): logical line storage for wrapped rows#5958

Closed
Tyriar wants to merge 1 commit into
masterfrom
cursor/logical-buffer-wrapped-lines-08e3
Closed

feat(buffer): logical line storage for wrapped rows#5958
Tyriar wants to merge 1 commit into
masterfrom
cursor/logical-buffer-wrapped-lines-08e3

Conversation

@Tyriar

@Tyriar Tyriar commented May 28, 2026

Copy link
Copy Markdown
Member

Summary

Implements the logical-line model described in #4800 for wrapped buffer rows: continuation rows share the parent BufferLine cell storage instead of duplicating data and relying on isWrapped on each physical row.

Changes

  • BufferLine: supports extended logical capacity (logicalCellCount) and segment-aware cell indexing via _segmentStart
  • BufferOverflowLine: viewport row that views a slice of the parent line's shared _data / attribute maps
  • BufferLineUtils: helpers to attach/clear wrapped rows, flatten logical groups for reflow, and create scroll-wrapped lines
  • Buffer API: attachWrappedRow, clearWrappedRow, createScrollWrappedLine
  • InputHandler: _unwrapBufferRow handles logical overflow rows when clearing wrap (e.g. backspace, erase); print path still uses isWrapped until reflow/SL integration is completed
  • Tests: BufferLogicalLine.test.ts covers shared storage across wrapped rows

Follow-up (not in this PR)

  • Wire attachWrappedRow into the InputHandler print/wrap hot path
  • Use materializeLogicalLinesForReflow before buffer reflow to simplify _reflowSmaller / _reflowLarger (avoid copying cells between rows that already share storage)
  • Optional: enable logical scroll-wrapped lines in BufferService.scroll

Testing

  • npm run test-unit -- out-esbuild/common/buffer/ out-esbuild/common/InputHandler.test.js (316 passing)
  • npm run lint-changes
Open in Web Open in Cursor 

Introduce BufferOverflowLine rows that share cell storage with a parent
BufferLine head, implementing the logical-line model from issue #4800.

- Extend BufferLine with logical capacity and segment-aware indexing
- Add BufferOverflowLine, BufferLineUtils helpers, and unit tests
- Expose attachWrappedRow/clearWrappedRow on Buffer for future integration
- Keep InputHandler on isWrapped flag until reflow/SL paths are updated

Reflow still uses per-row buffers; materializeLogicalLinesForReflow helpers
are included for a follow-up that simplifies resize reflow.

Co-authored-by: Daniel Imms <Tyriar@users.noreply.github.com>
@PerBothner

Copy link
Copy Markdown
Contributor

It's late, and I haven't had a chance to understand this change. However, I should point out that I believe that PR #5797 is a cleaner and more refined variation of the ideas in issue #4800: Instead of dealing with "overflow lines" it explicitly uses a LogicalLine class. PR #5853 builds on PR #5797 in also re-implementing Markers.

@Tyriar

Tyriar commented May 28, 2026

Copy link
Copy Markdown
Member Author

@PerBothner this is just me experimenting with a throw away agent implementation, I didn't want it to make the PR (still figuring out how to do that).

@Tyriar Tyriar closed this May 28, 2026
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.

3 participants