Skip to content

fix(core): adjust wide-character rendering boundaries in differential…#2009

Open
HarshaNaidu11 wants to merge 1 commit into
Karanjot786:mainfrom
HarshaNaidu11:fix-diff-renderer-wide-char
Open

fix(core): adjust wide-character rendering boundaries in differential…#2009
HarshaNaidu11 wants to merge 1 commit into
Karanjot786:mainfrom
HarshaNaidu11:fix-diff-renderer-wide-char

Conversation

@HarshaNaidu11

@HarshaNaidu11 HarshaNaidu11 commented Jul 3, 2026

Copy link
Copy Markdown

… renderer

Description

In Renderer._renderDiffLine, if a changed cell is a wide-character continuation cell (visual width = 0), the method correctly adjusts the starting column backwards to the primary cell (adjustedStart = Renderer._adjustSpanStart(...)) and generates a cursor moveTo for the primary cell. However, the subsequent render loop for (let sc = spanStart; sc < c; sc++) still starts at spanStart (the continuation cell) rather than adjustedStart. As a result, the terminal cursor is moved to the primary cell's column, but the character printed there is the continuation cell's character (often empty), shifting the actual characters to the left and corrupting the visual alignment of the line.

Related Issue

Closes #2006

Which package(s)?

Renderer.ts

Type of Change

  • 🐛 Bug fix (type:bug)
  • ✨ Feature (type:feature)
  • 📝 Docs (type:docs)
  • 🧪 Tests (type:testing)
  • ♻️ Refactor (type:refactor)
  • 🎨 Design / UX (type:design)
  • ♿ Accessibility (type:accessibility)
  • ⚡ Performance (type:performance)
  • 🔧 DevOps / CI (type:devops)
  • 🔒 Security (type:security)

Checklist

  • ⭐ You starred the repo. The needs-star check blocks your merge otherwise.
  • Tests pass locally: bun vitest run
  • Build passes: bun run build
  • Typecheck passes: bun run typecheck
  • You read CONTRIBUTING.md.
  • Your PR title follows type: short description.
  • Widget state mutators call markDirty() (if your change affects rendering).
  • No new any types without an inline comment explaining why.
  • No unrelated refactors bundled into this PR.

GSSoC 2026 Participation

  • You are a GSSoC 2026 contributor.

Screenshots / Recordings (UI changes)

Notes for the Reviewer

Summary by CodeRabbit

  • Bug Fixes
    • Improved rendering of changed text in terminal output so partially adjusted spans display correctly, including at the end of a line.

@github-actions github-actions Bot added area:core @termuijs/core type:bug +10 pts. Bug fix. needs-star PR author has not starred the repo. labels Jul 3, 2026
@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown

Hi @HarshaNaidu11 👋

Star this repo before your PR merges.

Why? GSSoC 2026 contributors who star get priority review and points credit. After you star, push any commit (or re-run this check). The needs-star label lifts automatically.

Thanks for your contribution to TermUI.

@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

In Renderer._renderDiffLine, the per-cell rendering loops for changed spans (both mid-row and trailing end-of-row spans) now start iteration from adjustedStart instead of spanStart, fixing a misalignment between cursor positioning and character output for wide-character continuation cells.

Changes

Diff Renderer Span Alignment Fix

Layer / File(s) Summary
Align render loop start with adjusted span position
packages/core/src/terminal/Renderer.ts
Both changed-span render loops now iterate starting from adjustedStart (from _adjustSpanStart) instead of spanStart, fixing cursor/character misalignment for wide-character continuation cells.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related PRs

  • Karanjot786/TermUI#1230: Both PRs modify _renderDiffLine's changed-span cell iteration/flush logic in the same rendering path.
  • Karanjot786/TermUI#1277: Both PRs modify _renderDiffLine flush logic to use adjustedStart instead of raw spanStart.

Suggested labels: quality:clean, level:beginner

Suggested reviewers: Karanjot786

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The code change matches #2006 by using the adjusted start for wide-character continuation spans.
Out of Scope Changes check ✅ Passed The PR is narrowly scoped to the renderer fix and shows no unrelated changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title is specific, matches the bug fix, and follows the required type: short description pattern.
Description check ✅ Passed The PR description matches the template and includes a clear summary, related issue, package info, type, and checklist.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions 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.

🎉 Thanks for your first PR to TermUI, @HarshaNaidu11.

Before your PR merges:

  1. Star the repo. Required. The star-check job blocks your merge otherwise.
  2. ✅ All checks green: build, test, typecheck.
  3. 🏷 PR title follows type: short description. Example: fix: handle empty list.
  4. 🔗 Link your closing issue in the description.

GSSoC 2026 points come from labels after merge:

  • gssoc:approved. +50 base points.
  • level:beginner / intermediate / advanced / critical. +20 / +35 / +55 / +80.
  • quality:clean / exceptional. x 1.2 / x 1.5.
  • type:*. Stackable bonus.

Your reviewer responds within 48 hours. Ping @Karanjot786 on Discord for urgent help.

🚀 Welcome to the cohort.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:core @termuijs/core needs-star PR author has not starred the repo. type:bug +10 pts. Bug fix.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] Differential Renderer wide-character layout corruption

1 participant