Repository navigation
Typographic substitution while typing (smart quotes + em dash) - #64
Conversation
Typing "/' becomes curly by context (open after line start, space or
([{—–; always ’ after a letter/digit), and a second - folds -- into —.
Backspace right after a substitution restores the straight characters,
which also serves as the escape. Lines that are only hyphens/spaces
(markdown rules) or contain | (tables) stay literal, as do inline code,
fenced blocks and frontmatter via a single literal_at() check that new
contexts (e.g. math) can extend. Paste is untouched.
New smart_quotes setting (on by default) persisted in store.rs, with a
toggle at the end of Settings → Editor in en and pt-BR.
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
A line typed linearly like `tail -- "z"` used to bake curls into what becomes a code span, because the tree only flags closed spans. A run of n backticks opens a span closed by a run of exactly n, so scan the line prefix in literal_at for an unmatched run (\\-escaped runs skipped). Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
Independent GUI verification on the release build (macOS, isolated config, real keystrokes via System Events; all claims byte-checked in the autosaved Passed: Edge found and fixed: linear-typed |
Summary
Adds typographic substitution on the typed-text path of
LiveEditor(smart quotes + em dash):"/'become curly by context: opens at line start or after space/(/[/{/—/–, closes otherwise; after a letter or digit'is always’(apostrophes:don’t,d’água).-folds--into—. Lines that are only hyphens/spaces (---rules, frontmatter fences) or contain|(table rows) stay literal.”→",—→--) — also the manual escape hatch.smart::literal_at(&Analysis, off)is the single extensible forbidden-context check.Analysisnow recordsmetadataranges forminus_metadata/plus_metadata; math ($…$, PR Add LaTeX math ($…$/$$…$$): Unicode editor rendering + MathML export #60) plugs into the same function at merge.replace_text_in_rangefor single typed chars.self.edit, so“/—undo as one step (undoing—restores the first-).smart_quotessetting (on by default) persisted instore.rs, with a toggle at the end of Settings → Editor ("Smart quotes" / "Aspas tipográficas").Core logic is pure and unit-tested:
smart::substitute(line, before, typed, on, literal) -> Option<Subst { text, orig, back }>— 6 tests cover open/close, apostrophe, fold, rule/table rejection, literal contexts and the off switch.GUI-verified (macOS release build)
“olá”,‘respondeu’,“don’t”,it’sand em dashes — byte-checked in the saved file.---,a | b -- c,`code -- "x"`and a fenced-- "y" and 'z'all stay literal.—→--and”→".--/"/'stay straight; persistssmart_quotes = offand re-enables live.Link to Devin session: https://app.devin.ai/sessions/4c6b312f7f904f8093d1bf890a1cf788
Open in Devin Desktop: https://app.devin.ai/desktop/session/4c6b312f7f904f8093d1bf890a1cf788?variant=devin
Requested by: @horizzon3507