Skip to content

Add spell checking with tap corrections and optional dictionary actions - #454

Merged
simonbs merged 11 commits into
mainfrom
codex/spell-checking
Oct 25, 2026
Merged

simonbs merged 11 commits into
mainfrom
codex/spell-checking

Conversation

@simonbs

@simonbs simonbs commented Oct 25, 2026 •

Copy link
Copy Markdown
Owner

Adds misspelling underlines and tap-to-correct suggestions using public UITextChecker APIs. Setting spellCheckingType = .yes enables checking independently of autocorrection; the private UIKit replacement-object workaround is removed.

On iOS 16 and later, tapping a misspelled word opens a compact system menu containing corrections. Tapping another word, blank space, or scrolling dismisses it. Selecting text still offers corrections in the regular edit menu. Earlier iOS versions use the regular edit-menu fallback.

Ignore Spelling, Learn Spelling, and Unlearn Spelling are hidden by default. Applications can independently expose them in spelling and regular edit menus:

textView.showIgnoreSpellingAction = true
textView.showLearnSpellingAction = true
textView.showUnlearnSpellingAction = true

These settings control menu visibility; public dictionary APIs remain available. Changes invalidate existing spelling actions. Ignored words belong to one editor's document session: edits, undo, language changes, and checking toggles preserve them; assigning text, calling setState, or explicitly resetting starts a new session. Learned words use Apple's shared dictionary. When enabled, selecting a learned word offers Unlearn Spelling even after its underline disappears. Dictionary actions preserve text, selection, and text undo history.

Checks are debounced, bounded, and scoped to visible text, including horizontally scrolled long lines. A dictionary language and delegate policy let applications exclude code or other ranges. Composing text is excluded and stale actions are rejected. Spelling pauses during Writing Tools sessions, and corrections use guarded system replacement with independent undo. Includes current main's Writing Tools improvements from #455, with exclusions and active-session edits preserved. Grammar integration and partial-word completion remain separate.

The example app includes a persistent Check Spelling setting, off by default.

Validation

  • 76 focused spelling and Writing Tools framework tests passed after merging current main on iOS 26.5 / Xcode 27.2. Coverage includes independent menu settings, dictionary APIs while actions are hidden, tap geometry and unavailable interaction states, ignore isolation/session reset, shared learning/unlearning, stale actions, delegate reentrancy, Unicode boundaries, bounded checks, rendering geometry, and Writing Tools undo coexistence. The merge regression also verifies that a range excluded from Writing Tools can still accept a spelling correction under its independent policy.
  • Three simulator UI workflows passed across the initial run and affected-case rerun: single-tap correction/dismissal/reopening/undo/disabling, ignore/reload, and learn/reload/unlearn. Tests assert default-hidden actions, unchanged document text for dictionary operations, and dictionary state with cleanup. The correction test passed after fixing a test tap that hit a suggestion and replacing a stale installed test runner.
  • Strict SwiftLint on changed Swift files and git diff --check passed. Existing language-package lint and XCTest deployment-target warnings remain.
  • Earlier implementation validation: 231 framework tests, example app build, and setting on/off/persistence checks passed. Those broader checks were not rerun for this update.

Launch the UI test Host and tap Spelling for the default correction menu or Dictionary for explicitly enabled dictionary actions. Run HostUITests/SpellCheckingTests for all three workflows.

The iOS 14/15 fallback has not been runtime-tested here. Actual Apple Intelligence generation was not exercised.

Simulator proof

Unmodified screenshots from passing UI tests. Captures support visual review; behavioral assertions are in the tests.

Single-tap suggestions, default settings Correction applied
Compact menu containing only spelling suggestions Correction applied
Opt-in Ignore / Learn Opt-in Unlearn
Explicitly enabled Ignore and Learn Spelling actions Explicitly enabled Unlearn Spelling for a learned word

Additional captures: undo, checking disabled, ignored word, and checking restored after Unlearn.

Example app setting from the earlier verified persistence check:

Example app menu with Check Spelling enabled after relaunch

Copilot AI balanced review requested due to automatic review settings October 25, 2026 16:02

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@simonbs simonbs changed the title Add public-API spell checking and correction menus Add public-API spell checking and dictionary actions Oct 25, 2026
@simonbs simonbs changed the title Add public-API spell checking and dictionary actions Add spell checking with tap corrections and optional dictionary actions Oct 25, 2026
@simonbs
simonbs enabled auto-merge (squash) October 25, 2026 17:09
@simonbs
simonbs merged commit acc9ecb into main Oct 25, 2026
9 checks passed
@simonbs
simonbs deleted the codex/spell-checking branch October 25, 2026 17:23
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.

2 participants