Skip to content

Announce whole-document replacements so spell check can re-run - #95

Draft
Wavesonics wants to merge 2 commits into
mainfrom
feat/document-replaced-signal
Draft

Announce whole-document replacements so spell check can re-run#95
Wavesonics wants to merge 2 commits into
mainfrom
feat/document-replaced-signal

Conversation

@Wavesonics

Copy link
Copy Markdown
Collaborator

setText replaces the document without emitting an edit operation, so nothing downstream can tell its text is gone. Spell check learned about a document only when the platform checker became available, which on Android beats the markdown import often enough that the one-shot check runs over an empty document and no squiggles ever appear.

The sample app worked around this with a second LaunchedEffect(spellChecker, markdownExtension) that re-ran the full check itself. Any host loading content programmatically needed the same workaround, and HtmlExtension's import had none.

TextEditorState now exposes documentReplacements, emitted from replaceContent (whose only callers are the two setText overloads), and SpellCheckingTextEditor runs a full check on it. The sample app's workaround is deleted.

Either race order costs one real scan: whichever of the checker and the document arrives last triggers the check, and the earlier one finds either no words or no checker. That removes the duplicate concurrent full check at load without needing any serialization.

Notes

BasicTextEditor calls setText when its text parameter changes, so a host driving text from state now gets a full re-check on each change. That is the intended behavior, but it is a behavior change rather than a pure cleanup.

A separate signal rather than a synthetic edit operation: emitting a real operation would be arguably more correct but ripples into undo/redo and every existing editOperations collector.

This is independent of #94, which stays drafted.

Tests

DocumentReplacementSignalTest covers the signal itself (setText emits, an edit does not). Two cases in SpellCheckE2eTest cover the behavior through the real editor stack: a document loaded into a composed editor gets checked, and replacing a document checks the new text. Both fail with the collector reverted; verified.

setText replaces the document without emitting an edit operation, so nothing
downstream could tell its text was gone. Spell check learned about a document
only when the platform checker became available, which on Android beat the
markdown import often enough that the one-shot check ran over an empty document
and no squiggles ever appeared. The sample app worked around it with a second
LaunchedEffect that re-ran the full check itself; any host loading content
programmatically needed the same workaround, and HtmlExtension's import had
none.

TextEditorState now exposes documentReplacements, and SpellCheckingTextEditor
runs a full check on it. Either race order costs one real scan: whichever of the
checker and the document arrives last triggers the check, and the earlier one
finds no words or no checker.
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@Wavesonics
Wavesonics marked this pull request as draft August 7, 2026 06:34
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