Skip to content

fix: prevent code ligatures from being applied when disabled in diff viewer#3034

Merged
gameroman merged 1 commit into
mainfrom
shuuji3/fix/ligature-in-diff-viewer
Jul 12, 2026
Merged

fix: prevent code ligatures from being applied when disabled in diff viewer#3034
gameroman merged 1 commit into
mainfrom
shuuji3/fix/ligature-in-diff-viewer

Conversation

@shuuji3

@shuuji3 shuuji3 commented Jul 12, 2026

Copy link
Copy Markdown
Member

🔗 Linked issue

fix #2754

🧭 Context

While the normal code viewer respects the ligature setting, the diff viewer ignores the same setting.

📚 Description

Ligatures style is applied here:

/* Settings-based configuration for code ligatures. On by default. */
:root[data-code-ligatures='false'] code {
font-variant-ligatures: none;
}

But the diff viewer has no <code> block in the code line. This change ensures to have <code> for each line and apply the ligatures setting.

Example result

In https://main.npmx.dev/diff/nitro/v/2.2.28...3.0.260610-beta?file=lib/class-file.js, this line if( this.__.src === undefined ) this.load(); will be rendered as follows:

Before

<td data-v-f41da3b8="" class="pe-6 text-nowrap">
  <del data-v-f41da3b8="">
    <span data-v-f41da3b8="" class="">
      <span class="line">
        <span style="color:#F97583;--shiki-light:#CD3443">    if</span><span style="color:#E1E4E8;--shiki-light:#24292E">( </span><span style="color:#79B8FF;--shiki-light:#005CC5">this</span><span style="color:#E1E4E8;--shiki-light:#24292E">.__.src </span><span style="color:#F97583;--shiki-light:#CD3443">===</span><span style="color:#79B8FF;--shiki-light:#005CC5"> undefined</span><span style="color:#E1E4E8;--shiki-light:#24292E"> ) </span><span style="color:#79B8FF;--shiki-light:#005CC5">this</span><span style="color:#E1E4E8;--shiki-light:#24292E">.</span><span style="color:#B392F0;--shiki-light:#6F42C1">load</span><span style="color:#E1E4E8;--shiki-light:#24292E">();
        </span>
      </span>
    </code>
  </del>
</td>

After

https://npmxdev-git-shuuji3-fixligature-in-diff-viewer-npmx.vercel.app/diff/nitro/v/2.2.28...3.0.260610-beta?file=lib/class-file.js

<td data-v-f41da3b8="" class="pe-6 text-nowrap">
  <del data-v-f41da3b8="">
    <code data-v-f41da3b8="" class="">
      <span class="line">
        <span style="color:#F97583;--shiki-light:#CD3443">    if</span><span style="color:#E1E4E8;--shiki-light:#24292E">( </span><span style="color:#79B8FF;--shiki-light:#005CC5">this</span><span style="color:#E1E4E8;--shiki-light:#24292E">.__.src </span><span style="color:#F97583;--shiki-light:#CD3443">===</span><span style="color:#79B8FF;--shiki-light:#005CC5"> undefined</span><span style="color:#E1E4E8;--shiki-light:#24292E"> ) </span><span style="color:#79B8FF;--shiki-light:#005CC5">this</span><span style="color:#E1E4E8;--shiki-light:#24292E">.</span><span style="color:#B392F0;--shiki-light:#6F42C1">load</span><span style="color:#E1E4E8;--shiki-light:#24292E">();
        </span>
      </span>
    </code>
  </del>
</td>

@vercel

vercel Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
npmx.dev Ready Ready Preview, Comment Jul 12, 2026 6:51am
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
docs.npmx.dev Ignored Ignored Jul 12, 2026 6:51am
npmx-lunaria Ignored Ignored Jul 12, 2026 6:51am

Request Review

@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The diff line renderer now wraps each rendered segment in a <code> element instead of a <span>, preserving the existing segment iteration, class binding, and HTML content rendering.

Changes

Diff rendering

Layer / File(s) Summary
Use code wrapper for rendered segments
app/components/Diff/Line.vue
Rendered diff segments are wrapped with <code> inside the dynamic line-kind component instead of <span>.
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The change satisfies #2754 by wrapping diff lines in , so the ligature setting can be applied consistently.
Out of Scope Changes check ✅ Passed The patch is narrowly scoped to the diff line wrapper change and introduces no obvious unrelated edits.
Title check ✅ Passed The title clearly describes the main diff viewer ligature fix and matches the changeset.
Description check ✅ Passed The description is directly related to the change and explains the ligature issue and fix.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch shuuji3/fix/ligature-in-diff-viewer

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.

@codecov

codecov Bot commented Jul 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@gameroman gameroman added this pull request to the merge queue Jul 12, 2026
Merged via the queue into main with commit 1c2f4ba Jul 12, 2026
29 checks passed
@gameroman gameroman deleted the shuuji3/fix/ligature-in-diff-viewer branch July 12, 2026 09:48
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.

Enable ligatures in code option is not respected in diff viewer

2 participants