Android diff viewer draws word-diff highlights at the wrong position when "monospace" resolves to a proportional font
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 78/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- android, typescript
調査の方向性
ReviewDiffCanvasDrawing.kt、特に drawWordDiffRanges を読み、ハイライト位置を drawCode が使用する測定済みの送り幅と比較してください。レポートでは、asciiFixedPitch がプロポーショナルなフォールバックを示す既存のシグナルとして挙げられています。プロポーショナルな等幅フォールバックを使用した Android の diff で再現してください。変更された単語のハイライトが変更された文字に揃い、隣接するテキストに重ならなければ完了です。
索引モデルが issue の本文から書いたものです。
説明
What happened
In the Android app's diff viewer (the Changes screen for a PR/turn), the red/green word-level highlights on changed lines are drawn in the wrong place. They are shifted to the right and are wider than the text they should mark, often covering unchanged characters or empty space after the line.
Example from the screenshot (to be attached below):
go.mod:go 1.25→go 1.27.3. On the deleted line the red highlight is an empty box after the end ofgo 1.25, not over the5.runbook.md:- `go ≥ 1.25` (builds `factory/cmd/role-assigner` …→- `go ≥ 1.27.3` …. The highlights land over`fa/s `fa(inside the path) instead of over the version number.
The code text in the diff is visibly rendered in a proportional font on this device, not a monospace one.
Diagnosis
ReviewDiffCanvasDrawing.drawWordDiffRanges positions every highlight by character index times the width of "M":
val characterWidth = textPaint.measureText("M")
...
val left = codeX + (start - lineStart) * characterWidth
val right = max(left + 2f * density, left + (end - start) * characterWidth)
This assumes the code typeface is fixed-pitch. The typeface is Typeface.create("monospace", …) (L524-L533), and on this device (OPPO Find X9 Pro, stock settings, no custom font chosen) that family resolves to a proportional font. The text itself is drawn with real measured advances (measureText per run in drawCode), so text and highlights drift apart. The error grows with the column, and highlights are too wide because "M" is wider than the average proportional glyph.
The same class already detects this case. asciiFixedPitch (L223, L274-L278, with the comment "Some system font weights resolve to proportional fallbacks even for "monospace"") is used for row width measurement (L316), but drawWordDiffRanges does not consult it. Measuring the prefix and range with textPaint.measureText(content, start, end) (or using asciiFixedPitch to choose that path) would align the highlights with the rendered text.
This code was introduced in #3967 and is unchanged on main (dd14848) and in Android beta 2.2.0 (735).
Steps to reproduce
- Use an Android device where the system
monospacefamily is not fixed-pitch (seen on an OPPO Find X9 Pro with default settings). - In the Android app, open a thread's Changes / PR diff view containing an edited line where the change is mid-line, e.g.
go 1.25→go 1.27.3in ago.mod. - Look at the red/green word-diff highlights on the deleted and added lines: they are offset to the right of the changed characters and too wide.
On a device whose monospace is genuinely fixed-pitch, the highlights line up (expected behavior).
Version
Android app 2.0.0 (code path unchanged through 2.2.0 beta and current main)
Environment
OPPO Find X9 Pro, Android (ColorOS, stock fonts), T3 Code Android app 2.0.0, connected to a T3 Code server on Linux
Evidence
# Screenshot attached separately: go.mod and runbook.md hunks in the Android Changes view
# showing word-diff boxes offset from the changed characters.
Related issues
#4582: monospace fell back to a proportional font on Android, but for React Native font-mono text surfaces (Uniwind font-family list). This report is the native review-diff canvas, which already requests monospace correctly but positions highlights as if it were fixed-pitch.
Fix applied or workaround
None. Nothing user-side changes the font resolution without a custom system font.
Filed by
Claude Code (Claude Opus 5.5, claude-opus-5-5) via t3 triage
- 主要言語
- TypeScript
- スター
- 24.8k
- フォーク
- 6.4k
- 平均マージ
- 3時間 20分
- マージ済み PR(30日)
- 208
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
pingdotgg/t3code のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
pingdotgg/t3code#27445 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
pingdotgg/t3code#27022 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
[Bug]: Device hub update button is clipped with long canary version strings対応中かも @juliusmarminge が 1 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
pingdotgg/t3code の issue をすべて見る
似ている issue
-
area:cli bug P4
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
bug from-studio
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
esengine/DeepSeek-Reasonix#14868 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
linxiv-dev/linXiv#384 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
scope:core type:security
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
mailgun/mailgun.js#544 ·