Skip to content

Make smart-quote substitution configurable via SpellCheckingPolicy - #189

Merged
luca-chen198 merged 2 commits into
nodes-app:mainfrom
Unireader:configurable-quote-substitution
Sep 29, 2026
Merged

luca-chen198 merged 2 commits into
nodes-app:mainfrom
Unireader:configurable-quote-substitution

Conversation

@xVanTuring

Copy link
Copy Markdown
Contributor

Problem

NativeTextViewWrapper.makeNSView sets isAutomaticQuoteSubstitutionEnabled = true unconditionally, and updateAutocorrectSettings sets it back to !shouldDisableSpelling on every caret move. An embedder that edits raw Markdown/LaTeX source therefore can't keep straight quotes: typing it's gives it’s, and $f'(x)$ gets ’ while the $…$ span is still unclosed (the caret isn't inside a recognized LaTeX token yet). Turning Smart Quotes off from the Edit menu doesn't last, because the next caret move out of a code/LaTeX/link span turns it back on.

Change

This follows the existing pattern for the three spelling toggles:

  • Add SpellCheckingPolicy.automaticQuoteSubstitution (default true, so behavior is unchanged) and apply it in makeNSView.
  • Add userPrefersAutomaticQuoteSubstitution to the coordinator. Outside suppress zones, updateAutocorrectSettings restores this preference instead of forcing the setting on. Inside code, LaTeX and links it is still forced off.
  • Override toggleAutomaticQuoteSubstitution so the menu choice is captured and reported through onSpellCheckingPolicyChanged, the same way the spelling toggles are.

Tests

  • New QuoteSubstitutionPolicyTests: the default stays on; turning it off survives moving out of code; turning it on is still suppressed inside code; the menu toggle is captured, reported and kept across caret moves.
  • RebuildSelectionReplayTests.rebuildAppliesAutocorrectForLoadedCaret now checks against the preference.
  • swift build and swift test pass (516 tests).

CHANGELOG entry added under [Unreleased].

…maticQuoteSubstitution)

Upstream 0.13.0 hard-codes isAutomaticQuoteSubstitutionEnabled = true and turns it
back on whenever the caret leaves a code/LaTeX/link span, so Markdown/LaTeX source
gets ’ instead of '. Follow the existing spelling-toggle pattern: initial value from
the policy, user menu toggle captured and preserved across caret moves.
@luca-chen198
luca-chen198 merged commit 16c2b0c into nodes-app:main Sep 29, 2026
1 check passed
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