Open
Conversation
…sion (arnog#2974) Defer implicit argument deletion until after fraction insertion and repair orphaned parent references left by deleteAtoms. Add null-safety throughout model.at() call sites and leftSibling traversals. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…Runs Two bugs caused duplicate ML__caret elements in rendered output: 1. getStyleRuns pushed "first" atoms twice into the same style run (missing `continue` after the type check) 2. insertSmartFence case 2.2 didn't filter "first" atoms from extractAtoms results, causing root.body and leftright.body to share the same first atom object Also adds a WHY comment for the null cursor fallback in insert(). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fixes #2974
Description
Fixes two related bugs when building parenthesized expressions via keyboard (e.g. typing 5 ) Home ( End /):
1. Empty/unresponsive mathfield after fraction insertion (#2974)
Typing
/after a specific input sequence (e.g.1 ) Home ( End) caused the field to become empty and unresponsive. The root cause was that deleting the implicit argument before inserting the fraction left the field empty, breaking cursor positioning. Subsequent Ctrl+A / Delete / retype also failed due to orphaned parent references left behind by deleteAtoms.Fix: defer implicit argument deletion until after fraction insertion, then repair any orphaned parent pointers in
root.body. Also adds null-safety guards throughoutmodel.at()call sites andleftSiblingtraversals ingetImplicitArgOffset.2. Phantom duplicate caret
After the
1 ) Home (sequence, two blinking cursors appeared instead of one. Two independent bugs contributed:getStyleRunsinatom-class.tspushed "first" atoms into a style run twice (missing continue after the type-check branch), causing them to render twice.insertSmartFencecase 2.2 inkeyboard-input.tsdidn't filter "first" sentinel atoms out of extractAtoms results when the extraction range started at offset 0. This causedroot.bodyandleftright.bodyto share the same first atom object — so setting.careton it produced a caret in both render locations.Demo
Before
Screen.Recording.2026-03-29.at.19.46.35.mov
After
Screen.Recording.2026-03-29.at.19.43.00.mov