Repository navigation
Make smart-quote substitution configurable via SpellCheckingPolicy - #189
Merged
luca-chen198 merged 2 commits intoSep 29, 2026
Merged
Conversation
…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.
3 tasks done
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.
Problem
NativeTextViewWrapper.makeNSViewsetsisAutomaticQuoteSubstitutionEnabled = trueunconditionally, andupdateAutocorrectSettingssets it back to!shouldDisableSpellingon every caret move. An embedder that edits raw Markdown/LaTeX source therefore can't keep straight quotes: typingit'sgivesit’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:
SpellCheckingPolicy.automaticQuoteSubstitution(defaulttrue, so behavior is unchanged) and apply it inmakeNSView.userPrefersAutomaticQuoteSubstitutionto the coordinator. Outside suppress zones,updateAutocorrectSettingsrestores this preference instead of forcing the setting on. Inside code, LaTeX and links it is still forced off.toggleAutomaticQuoteSubstitutionso the menu choice is captured and reported throughonSpellCheckingPolicyChanged, the same way the spelling toggles are.Tests
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.rebuildAppliesAutocorrectForLoadedCaretnow checks against the preference.swift buildandswift testpass (516 tests).CHANGELOG entry added under
[Unreleased].