Android diff viewer draws word-diff highlights at the wrong position when "monospace" resolves to a proportional font
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 2/5
- Temps estimé
- 1-3 heures
- Accessibilité débutants
- 78/100
- Type d'issue
- Bug
- Clarté
- Clairement spécifiée
- Activité
- Active
- Stack technique
- android, typescript
Piste de recherche
Lisez ReviewDiffCanvasDrawing.kt, en particulier drawWordDiffRanges, et comparez les positions des surlignages aux avances mesurées utilisées par drawCode. Le rapport identifie asciiFixedPitch comme un signal existant pour les polices de remplacement à chasse proportionnelle. Reproduisez le problème avec un diff Android utilisant une police de remplacement à chasse proportionnelle ; le travail est terminé lorsque les surlignages des mots modifiés s’alignent sur les caractères modifiés sans recouvrir le texte adjacent.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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
- Langage dominant
- TypeScript
- Étoiles
- 24.8k
- Forks
- 6.4k
- Merge moyen
- 3 h 20 min
- PR mergées (30 j)
- 208
Préparer son environnement
Lance le conteneur de développement du projet dans votre navigateur, avec votre propre compte GitHub.
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de pingdotgg/t3code
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
pingdotgg/t3code#27445 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 64/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 74/100
pingdotgg/t3code#27022 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
[Bug]: Device hub update button is clipped with long canary version stringsPeut-être pris @juliusmarminge l’a pris il y a 1 jour. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de pingdotgg/t3code
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 85/100
Automattic/data-liberation-agent#1115 ·
Les mainteneurs répondent en général sous 1 jour
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 88/100
Les mainteneurs répondent en général sous 1 jour
-
Enhance blog readabilityOuverteCSS enhancement good first issue
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
pychess/pychess-variants#2448 ·
Les mainteneurs répondent en général sous 1 jour
-
[architect] Stale planning/scratch files at repo root (COMPONENT_SPLIT_SUMMARY.md etc.) describe already-completed workPeut-être pris @hivecommons-hive l’a pris aujourd’hui. Ouverteagent/architect architecture help wanted stage/040-covered-by-pr tech-debt
Difficulté 2/5 1-3 heures Accessibilité débutants 85/100
kubestellar/console#24716 ·
Les mainteneurs répondent en général sous 1 jour
-
helm-knative-apply.sh fails with Helm 4Peut-être pris Une pull request liée à cette issue est ouverte ou déjà fusionnée. Ouvertearea: triage theme: undefined
Difficulté 2/5 1-3 heures Accessibilité débutants 85/100
jhipster/generator-jhipster#35895 ·
Les mainteneurs répondent en général sous 1 jour