Skip to content

feat: word-wrap — soft wrap in VisualLineBuilder + Editor.WordWrap + ted toggle#106

Merged
tig merged 4 commits into
developfrom
copilot/add-word-wrap-implementation
May 13, 2026
Merged

feat: word-wrap — soft wrap in VisualLineBuilder + Editor.WordWrap + ted toggle#106
tig merged 4 commits into
developfrom
copilot/add-word-wrap-implementation

Conversation

Copilot AI commented May 13, 2026

Copy link
Copy Markdown
Contributor
  • Create WordWrapStrategy.cs — walks grapheme clusters, breaks at whitespace or hard-breaks, produces WrapSegment list
  • Add BuildWrapped method to VisualLineBuilder — emits multiple CellVisualLines per document line when wrapping
  • Add Editor.WordWrap property with cache invalidation
  • Update Editor.Drawing.cs and caret logic to account for word wrap (visual line count, caret positioning, vertical movement)
  • Update UpdateContentSize to reflect wrapped line count
  • Add word-wrap toggle in ted's Options menu
  • Add unit tests for WordWrapStrategy (break at whitespace, CJK hard-break)
  • Add caret-under-wrap and vertical movement integration tests
  • Record decision: continuation lines flush at column 0 for v1
  • Address code review (remove TextDocument temp allocations, simplify ternary expressions)
  • Fix P1: Invalidate wrap map on viewport resize and fold changes
  • Fix P2: Apply selection after transformers in wrapped line rendering
  • Add tests proving both CR issues (520 tests passing)

Copilot AI and others added 2 commits May 13, 2026 14:35
…gle)

- New WordWrapStrategy.cs: breaks at whitespace boundaries, hard-breaks
  CJK/no-whitespace runs, produces WrapSegment list
- VisualLineBuilder.BuildWrapped: emits multiple CellVisualLines per
  document line when wrapping is active
- Editor.WordWrap property with full cache invalidation
- Wrap-aware caret positioning and vertical movement
- DrawWrappedLines in Editor.Drawing.cs
- UpdateContentSize accounts for wrapped row count
- ted Options menu: Word Wrap checkbox toggle
- DEC-005: continuation lines flush at column 0 for v1
- Unit tests for WordWrapStrategy (whitespace break, CJK hard-break,
  empty text, multiple spaces)

Agent-Logs-Url: https://github.com/gui-cs/Editor/sessions/35f21281-34ff-41f4-a19b-fd5b6e5e355f

Co-authored-by: tig <585482+tig@users.noreply.github.com>
Copilot AI changed the title [WIP] Implement soft word wrap feature in VisualLineBuilder feat: word-wrap — soft wrap in VisualLineBuilder + Editor.WordWrap + ted toggle May 13, 2026
Copilot AI requested a review from tig May 13, 2026 14:44
Copilot finished work on behalf of tig May 13, 2026 14:44
@tig
tig marked this pull request as ready for review May 13, 2026 14:48

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fda01e2f9c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/Terminal.Gui.Editor/Editor.cs Outdated
Comment thread src/Terminal.Gui.Editor/Editor.Drawing.cs Outdated
@tig

tig commented May 13, 2026

Copy link
Copy Markdown
Member

@copilot see CR feedback. Ensure there's a test that proves the CR feedback (or not) and then fix.

…selection after transformers

P1: GetWrapMap() now tracks the wrap column used to build the map and
automatically rebuilds when viewport width changes. Also invalidated
on fold toggle via OnFoldingChanged.

P2: BuildWrappedSegmentVisualLine now applies selection AFTER
transformers, matching the non-wrapped path. This prevents syntax
highlighters from overwriting selection attributes.

Includes integration tests proving both issues:
- WrapMap_Rebuilds_On_Viewport_Width_Change
- Selection_Survives_Transformers_In_Wrapped_Mode

Agent-Logs-Url: https://github.com/gui-cs/Editor/sessions/670dca0d-0122-4843-a2ec-ae6fbed2fc65

Co-authored-by: tig <585482+tig@users.noreply.github.com>

Copilot AI commented May 13, 2026

Copy link
Copy Markdown
Contributor Author

@copilot see CR feedback. Ensure there's a test that proves the CR feedback (or not) and then fix.

Fixed in 8057517. Both CR issues addressed:

P1 (wrap map stale on resize/fold): GetWrapMap() now stores the wrap column used to build the map and auto-rebuilds when the viewport width changes. Also explicitly invalidated in OnFoldingChanged. Test: WrapMap_Rebuilds_On_Viewport_Width_Change — starts at 20-col viewport (line wraps), resizes to 40-col (line fits on one row), asserts second row is now blank.

P2 (selection overwritten by transformers): BuildWrappedSegmentVisualLine now applies selection AFTER transformers, matching the non-wrapped path in VisualLineBuilder.Build(). Test: Selection_Survives_Transformers_In_Wrapped_Mode — adds an OverwriteTransformer that paints everything red, selects text, asserts selected cells get the Active role attribute (not red).

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

Copilot finished work on behalf of tig May 13, 2026 15:06
@tig
tig merged commit ef33402 into develop May 13, 2026
@tig
tig deleted the copilot/add-word-wrap-implementation branch May 13, 2026 15:10
tig added a commit that referenced this pull request May 17, 2026
…rvey

All four beta features (find-and-replace #104, clipboard #107, word-wrap
#106, multi-caret #105) plus vertical-multi-caret #133 and syntax-theme
Phase 2 #134 have merged since the 2026-05-13 plan snapshot. Bring the
spec set back in line with develop:

- Per-feature status lines -> Done with PR/issue refs (clipboard,
  multi-caret, find-and-replace, word-wrap, vertical-multi-caret,
  syntax-theme).
- plan.md rescoped to the beta endgame: new "Done (beta)" table, a
  "Remaining for beta" that reflects no feature work is left (only
  external/verification/cut items), evidence-checked DoD boxes,
  refreshed dependency graph and header.
- decisions.md: OPEN-005 annotated as settled by syntax-theme; add
  OPEN-006 (single-line/input-mode decision).
- codex-autonomous-sprint.md: flag stale work pool.
- New specs/textview-parity-gap/spec.md: survey of TextView
  capabilities Editor lacks (autocomplete, overwrite mode,
  single-line mode, kill-ring, context menu) with dispositions;
  wired into plan.md follow-ups.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

word-wrap: soft wrap in VisualLineBuilder + Editor.WordWrap + ted toggle

2 participants