b670b436c33fdf9784f6485e82e2c6a07082b49b
insertAtCursor's textarea-fallback branch advanced lastEmittedRef to the post-insertion value. The mount effect's dynamic import() closes over `value` as of initial render, so if CodeMirror finishes loading after a fallback-mode insertion, it mounts with the pre-insertion doc. The only repair mechanism -- the value-sync effect -- is gated on `value !== lastEmittedRef.current`, so advancing that ref made the gate see them as already equal and skip the repair, silently dropping the insertion. Also clamps caretOffset to [0, text.length] defensively, and adds coverage for a non-empty-selection replace and for the fallback-to-CodeMirror-mount transition itself (using the real @codemirror/* packages, no mocks). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Languages
TypeScript
75.9%
JavaScript
12.3%
HTML
8.6%
CSS
2.6%
PHP
0.4%
Other
0.2%