Skip to content

Stop words from jumping lines while you type - #5

Merged
Byntham merged 1 commit into
mainfrom
t3/caret-no-word-split
Nov 5, 2026
Merged

Byntham merged 1 commit into
mainfrom
t3/caret-no-word-split

Conversation

@Byntham

@Byntham Byntham commented Nov 5, 2026

Copy link
Copy Markdown
Owner

Problem

When you type near the end of a line, the word you are typing splits in two. The typed part stays on line 1 and the rest of the word jumps to line 2 ("whe" / "re"). Words keep moving as you type, which makes the prompt hard to read.

The caret was an inline-block. Browsers allow a line break next to an inline-block, so the line could wrap at the caret, in the middle of a word.

Fix

The caret is now a plain inline span, and an absolutely positioned ::after draws the bar. A plain inline span adds no break point, so the text wraps the same way it would without a caret.

Proof

Same prompt, 880px window, after typing "cut until the e".

Before, "eval" splits around the caret:

Before: the word eval split across two lines at the caret

After, "eval" stays whole on line 2:

After: the word eval stays whole on the second line

A new Playwright check (checkWordsStayPutWhileTyping) types a seeded prompt one key at a time at 11 widths from 800px to 1200px. After each key it checks that no character changed lines. It failed on the old CSS (11 keys moved words) and passes now. Lint, typecheck, unit tests and the full npm test pass. I tested in Chromium only. WebKit would not install on this Linux box, so Safari is untested.

Reviewed with sol-loop: 1 round with gpt-6.1-sol. Sol verdict: approved

Created with Claude Opus 5.5 in Claude Code. Reviewed by GPT-6.1 Sol in Codex.

🤖 Generated with Claude Code

The caret was an inline-block, which gives the browser a line-break point
between typed and ghost text. A word at the line end split around the caret.
Draw the caret as a plain inline span with an absolutely positioned bar.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Byntham
Byntham merged commit 4f51563 into main Nov 5, 2026
1 check passed
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.

1 participant