Skip to content

fix(ui): make word wrap work in side-by-side diff view#450

Merged
agavra merged 7 commits into
agavra:mainfrom
yuhua99:main
Jul 8, 2026
Merged

fix(ui): make word wrap work in side-by-side diff view#450
agavra merged 7 commits into
agavra:mainfrom
yuhua99:main

Conversation

@yuhua99

@yuhua99 yuhua99 commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Fixes #441.

Sorry for the delay on this one — work has been busy the past while, so
it took me a bit to get the PR out.

Fix

Introduce a span-level word wrapper (wrap_spans) and route both views through it, so the same code that renders rows also produces their heights. Side-by-side additionally wraps each column independently and keeps the divider aligned on continuation rows.

Commits

  1. feat(ui): add span-level word wrapper wrap_spans:
    style-preserving word wrapper primitive; no callers yet.
  2. refactor(ui): share wrap-aware cursor-line highlight across diff views:
    extract a common paint_cursor_line_highlight that walks row_heights so unified and side-by-side can't drift on wrapped rows.
  3. refactor(ui): simplify side-by-side pair loop and expanded-context helper:
    some cleanup to make room for the meta insertion in handle multiple sessions / multiple repositories #5.
  4. fix(ui): single-pass wrap in unified view so row heights match rendered rows:
    replace Paragraph::wrap + compute_row_heights dual pass with one wrap_spans call producing both the visual rows and their heights.
  5. feat(ui): per-column word wrap in side-by-side view:
    the actual fix. Record SbsRowMeta (raw content, prefix, pad style) per logical line at build time, then wrap each column at content_width with -preserving continuation prefixes. Deletes the now-unused compute_row_heights.
  6. fix(ui): extend comment-box gutter bar over wrapped rows:
    draw the comment-box vertical bar across every wrapped sub-row instead of stopping at the first visual row.
  7. feat(ui): replace front-draining with cursor walk in wrap_spans hard split:
    perf. make it faster

@agavra agavra left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks @yuhua99 this is a clear improvement. Some things don't work great (like zz doesn't always compute the correct center) though we can file those as follow ups as we figure it out.

@agavra
agavra merged commit 9f1b4ec into agavra:main Jul 8, 2026
4 checks passed
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 has no effect in side-by-side diff view

2 participants