A lone CR in a textarea is laid out as one line but drawn as two on macOS, so rows overprint
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 64/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- macos, zig
- Ambito
- desktop
Direzione di ricerca
Start with the line-breaking and wrapping logic in src/primitives/canvas/text_layout.zig at the cited locations, then compare it with macOS drawing in src/platform/macos/appkit_host.m and measurement in src/primitives/canvas/text_metrics.zig. Trace how pasted separators reach the textarea and host. Done means lone CR and the other confirmed separators no longer cause layout, drawing, and measurement to disagree.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Pasting text whose paragraphs are separated by a lone \r into a textarea draws the words after each CR one row lower, on top of the next wrapped row. The text itself is intact; only the drawing is wrong. U+2028 and vertical tab (0x0B) do the same. LF and CRLF draw correctly.
Seen with CLI 0.10.1 on macOS; the code below is as of 6b05318 on main.
Reproduction. A fixed-width textarea (mine is 484pt), four paragraphs of prose separated by a single \r, each long enough to wrap two or three times. Paste it (native automate widget-key <view> cmd+v reproduces it too). In the host render the first words of each paragraph after the first are drawn over that paragraph's first wrapped row.
What I found in the source
- Layout breaks a line only at LF (
src/primitives/canvas/text_layout.zig:761,:793,:840) and wraps only at space or tab (isTextBreakByte,:1088). Soend.\rNextis one unbreakable word on one row. - The macOS host draws a row through NSLayoutManager (
src/platform/macos/appkit_host.m:2093-2106), which treats\ras a paragraph break, so the part after the CR is drawn a line lower. - Width measurement on macOS uses
sizeWithAttributes:(appkit_host.m:2539), which returns the width of the widest line for a string containing\r, someasureTextAdvance(src/primitives/canvas/text_metrics.zig:98) gives every character after a CR an advance of 0. The reference renderer (native automate screenshot) accordingly draws those characters collapsed into one cell. - The paste keeps
\ras pasted.
U+2029, U+0085 and FF should behave the same (NSLayoutManager breaks at them and the layout does not); I have only read that, not pasted it.
Possible fixes. Treat a lone CR (and the other separators) as a hard break wherever LF is one, or normalize them to LF when text enters a textarea. Either way, the text handed to the host for one row should not contain a character the host breaks at.
A related gap. A TEA app cannot tell a textarea where its caret is: Widget has text_selection, but ui.el's ElementOptions has no field for it and widgetFromOptions never sets it. So when an app's model text differs from the editor's copy (here, because the app normalized a paste), the editor takes the app's text, puts the caret at the end, and its undo history for the field restarts. Letting ElementOptions carry a text_selection through to the widget would let an app keep the caret where the edit left it.
In Plaza I work around it by turning those separators into LF before an edit reaches the model, leaving CRLF alone, and moving the model's caret to the end when a paste had to change (zig-nostr/plaza#388).
- Lingua principale
- Zig
- Stelle
- 7.9k
- Fork
- 335
- Merge medio
- 10h 33m
- PR unite (30g)
- 147
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di vercel-labs/native
-
Per-view widget layout budget (1024 nodes) drops whole frames on real multi-pane app viewsForse già presa @slicenferqin l’ha presa 100 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
vercel-labs/native#408 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
vercel-labs/native#387 ·
I maintainer di solito rispondono entro 1 giorno
-
macOS: the window frame event reports the frame size where everything else expects the content sizeAperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 84/100
vercel-labs/native#355 ·
I maintainer di solito rispondono entro 1 giorno
-
cef.zig: InstallResult.archive_path leaks on successForse già presa @versecafe l’ha presa 206 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
vercel-labs/native#32 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
vercel-labs/native#957 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di vercel-labs/native
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
GUI: the space panel stays stale after a run stops with no spaceForse già presa @nikkexe0-del l’ha presa oggi. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
xevrion/hatchzip#237 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
flathub/org.ardour.Ardour#89 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
Javis603/token-monitor#1861 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 92/100
I maintainer di solito rispondono entro 1 giorno