[PR #3935] [MERGED] Preserve the input caret after typographic quotes #6165

Closed
opened 2026-10-23 04:07:43 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/3935
Author: @SpicyMarinara
Created: 7/22/2026
Status: ✅ Merged
Merged: 7/22/2026
Merged by: @SpicyMarinara

Base: staging ← Head: agent/typographic-quote-caret


📝 Commits (1)

  • c7dc887 fix: preserve caret after typographic quotes

📊 Changes

2 files changed (+54 additions, -1 deletions)

View changed files

📝 e2e/core-flows.e2e.ts (+52 -0)
📝 packages/client/src/lib/text-selection.ts (+2 -1)

📄 Description

What changed

  • Stops delayed quote-selection restoration when the textarea has received newer text.
  • Adds browser regression coverage for an apostrophe in wasn't and text following a double quote.

Why

Typographic quote formatting restores the captured selection across a microtask and two animation frames so React renders do not move the caret. A later keystroke could arrive before those callbacks completed, allowing an older selection to overwrite the browser's newer caret position.

The restoration now proceeds only while the textarea still contains the exact value that scheduled it. Typing or otherwise changing the value makes the stale callback inert.

Fixes #3934

Validation performed

  • pnpm check
  • pnpm exec playwright test -c playwright.config.ts e2e/core-flows.e2e.ts --grep "typographic quotes do not pull" (1 passed, 1 mobile skip by design)
  • git diff --check

Manual verification

  • Enable typographic quotes and type wasn't quickly in the Roleplay input; verify the caret remains after t.
  • Type a double quote followed immediately by a letter; verify the caret remains after the letter.

Summary by CodeRabbit

  • Bug Fixes

    • Fixed text cursor positioning when typographic quotes are automatically applied, preventing the caret from jumping behind later text.
    • Improved selection restoration so it does not overwrite the cursor position after the text content changes.
  • Tests

    • Added end-to-end coverage for typographic quote formatting and cursor placement.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/3935 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 7/22/2026 **Status:** ✅ Merged **Merged:** 7/22/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `agent/typographic-quote-caret` --- ### 📝 Commits (1) - [`c7dc887`](https://github.com/Pasta-Devs/Marinara-Engine/commit/c7dc887dff448870ce3dd229d7359fceff892698) fix: preserve caret after typographic quotes ### 📊 Changes **2 files changed** (+54 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `e2e/core-flows.e2e.ts` (+52 -0) 📝 `packages/client/src/lib/text-selection.ts` (+2 -1) </details> ### 📄 Description ## What changed - Stops delayed quote-selection restoration when the textarea has received newer text. - Adds browser regression coverage for an apostrophe in `wasn't` and text following a double quote. ## Why Typographic quote formatting restores the captured selection across a microtask and two animation frames so React renders do not move the caret. A later keystroke could arrive before those callbacks completed, allowing an older selection to overwrite the browser's newer caret position. The restoration now proceeds only while the textarea still contains the exact value that scheduled it. Typing or otherwise changing the value makes the stale callback inert. Fixes #3934 ## Validation performed - `pnpm check` - `pnpm exec playwright test -c playwright.config.ts e2e/core-flows.e2e.ts --grep "typographic quotes do not pull"` (1 passed, 1 mobile skip by design) - `git diff --check` ## Manual verification - [ ] Enable typographic quotes and type `wasn't` quickly in the Roleplay input; verify the caret remains after `t`. - [ ] Type a double quote followed immediately by a letter; verify the caret remains after the letter. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Bug Fixes** - Fixed text cursor positioning when typographic quotes are automatically applied, preventing the caret from jumping behind later text. - Improved selection restoration so it does not overwrite the cursor position after the text content changes. - **Tests** - Added end-to-end coverage for typographic quote formatting and cursor placement. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-23 04:07:43 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#6165
No description provided.