Find and Replace: a quote typed in Replace with goes in curly when smart quotes are on (#7949)

Co-Authored-By: RickiNano <81099017+RickiNano@users.noreply.github.com>
This commit is contained in:
RickiNano authored and GitHub committed 2026-11-28 21:59:13 +00:00
1 parent 4767a33981
commit 1b75d8dfd4
7 files changed
+229 -12

No files matched your search

+2
View File
@@ -170,6 +170,7 @@ Ranked, to beta (detail and remaining milestones in [docs/roadmap.md](docs/roadm
- 2026-11-15: Native, built-in and web Insert/Change Picture choosers offer both TIFF extensions (`.tif`, `.tiff`) alongside other supported pictures; native drops, picked-file inbox dispatch and pasted picture paths recognize the same suffixes (#6704). TIFF decoding remains limited to supported compression.
- 2026-11-27: Replace with curls a quote typed there when smart quotes are on, as typing does: finding `^034` and replacing with a typed `"` curls stray straight quotes in bulk; `^034` and `^039` stay straight, and a curly quote a typed `'` also finds is left and not counted (#7307).
- 2026-11-15: Get the Missing Fonts. A document opened from a file that is missing fonts their publisher gives away (Microsoft's Aptos family, the default in recent Word documents; Cascadia Code and Mono) brings up a box naming each font, the font drawn instead, the publisher's download page and how to install the download, with Don't show this again. `font.missing` reports the same page, so agents get it without the box. WordCraft links to the page only; it downloads and bundles nothing.
- 2026-10-30: Track Changes: a list item deleted whole, text and paragraph mark, shows its number as deleted text, in the deletion's colour and with its mark (struck through by default, or caret, #, bold, italic, underline), and hides it with No Markup or when Track Changes Options hide deletions (#4828). Readiness unchanged.
- 2026-11-03: A picture inserted or pasted in a table cell fits the cell, as in Word, instead of running out of it; in text columns it fits the column, in a section with other margins that section's width (#5428).
@@ -981,6 +982,7 @@ MATH glyphs that reference the same construction now share its immutable variant
| Date | Change | Summary |
|---|---|---|
| 2026-11-27 | trivial | Progress log: a quote typed in Replace with goes in curly when smart quotes are on (#7307) |
| 2026-11-18 | trivial | DOCX validation reports undeclared binary tombstones in coverage notes when relationship discovery establishes that no relationship targets the part. |
| 2026-11-18 | trivial | DOCX validation excludes the content-type manifest from main-part cardinality and reports untargeted ordinary document parts in coverage when one ordinary main is established. |
| 2026-11-18 | trivial | DOCX validation warns on an image signature mismatch when the image is unused or can be decoded in another raster format. Used, unusable images retain their error. |
+36 -6
View File
@@ -161,7 +161,7 @@ pub fn specs() -> Vec<CommandSpec> {
.params(r#"{"tab"?: "find|replace|goto" (default replace)}"#)
.pure(),
CommandSpec::new("edit.replaceAll", "Replace All", "Home › Editing › Replace", replace_all)
.params(r#"{"text": string, "with": string (^p ^t ^& ^c …; \\1 with wildcards; with regex also $1 ${n} ${name} $0 $$ \\1 \\n (paragraph mark) \\t), …options of edit.find}"#),
.params(r#"{"text": string, "with": string (^p ^t ^& ^c …; \\1 with wildcards; with regex also $1 ${n} ${name} $0 $$ \\1 \\n (paragraph mark) \\t), …options of edit.find} (with AutoFormat's smart quotes on, a " or ' typed in `with` goes in curly by the character before it, as typing does, except with regex or special: false (taken as written); ^034 and ^039 stay straight; a match that already reads so, curled the same kind, is left and not counted)"#),
CommandSpec::new("edit.goto", "Go To", "Home › Editing › Find", goto)
.key("Mod+Alt+G / F5")
.params(r#"{"page"?: n, "pageBy"?: int (pages forward, negative back, from the caret's page), "bookmark"?: string (selects its text), "paragraph"?: n}; none opens Find and Replace on its Go To tab"#)
@@ -496,6 +496,9 @@ pub(crate) struct Found {
pub a: Pos,
pub b: Pos,
pub rep: Option<String>,
/// With smart quotes on, the match already is its replacement with the quotes curled the
/// same kind (a curly apostrophe a typed `'` found): Replace leaves it and doesn't count it.
pub keep: bool,
}
/// A stretch of searched text: `len` bytes from `hay` are paragraph `para`'s bytes from `raw`.
@@ -535,6 +538,13 @@ fn find_opts(f: &crate::session::FindState) -> find_pattern::Opts {
/// wildcard groups). A pattern that can match a paragraph mark (`^p`) reads runs of sibling
/// paragraphs as one text with a mark between them; otherwise each paragraph is read alone.
pub(crate) fn search_full(s: &Session, story: StoryRef, with_rep: bool) -> Result<Vec<Found>, CmdError> {
search_matches(s, story, with_rep, false)
}
/// [`search_full`]. With `chain` (Replace All, which replaces every match), a quote typed in
/// Replace with curls by the previous match's replacement when the two touch; without it, by the
/// text as it is, since Replace changes only the selected match (#7307).
fn search_matches(s: &Session, story: StoryRef, with_rep: bool, chain: bool) -> Result<Vec<Found>, CmdError> {
use regex_automata::{Input, meta, util::syntax};
let f = &s.find;
if f.query.is_empty() {
@@ -551,6 +561,9 @@ pub(crate) fn search_full(s: &Session, story: StoryRef, with_rep: bool) -> Resul
let index = |name: &str| re.group_info().to_index(regex_automata::PatternID::ZERO, name);
find_pattern::resolve_names(find_pattern::parse_replace(&f.replace, &opts), &index)
});
// "Straight quotes with smart quotes" curls a quote typed in Replace with (#7307).
let ac = &s.prefs.autocorrect;
let smart = ac.enabled && ac.smart_quotes && pieces.as_deref().is_some_and(find_pattern::has_typed_quote);
let paths = s.doc.para_paths(story);
// Paragraphs read as one text: consecutive siblings when the pattern spans paragraphs.
let mut chunks: Vec<std::ops::Range<usize>> = Vec::new();
@@ -613,6 +626,8 @@ pub(crate) fn search_full(s: &Session, story: StoryRef, with_rep: bool) -> Resul
};
cuts.push(hay.len());
let mut from = 0;
// Where the last match ends and the character that stands there once it is replaced.
let mut last: Option<(usize, Option<char>)> = None;
for cut in cuts {
if cut <= from {
continue;
@@ -636,11 +651,24 @@ pub(crate) fn search_full(s: &Session, story: StoryRef, with_rep: bool) -> Resul
continue;
}
let (Some(a), Some(b)) = (pos_of(m.start(), false), pos_of(m.end(), true)) else { continue };
let found = hay.get(m.range()).unwrap_or("");
// A quote curls by the character in front of the match as it will read: with
// `chain`, the previous match's replacement when the two touch. A section mark
// starts a paragraph.
let before = match last {
Some((end, c)) if chain && end == m.start() => c,
_ => hay.get(..m.start()).and_then(|t| t.chars().next_back()),
}
.filter(|c| *c != find_pattern::SECT_MARK);
let quotes = if smart { find_pattern::Quotes::Smart { before } } else { find_pattern::Quotes::Straight };
let rep = pieces.as_ref().map(|pc| {
let group = |n: usize| caps.get_group(n).and_then(|g| hay.get(g.range())).map(str::to_string);
find_pattern::expand(pc, hay.get(m.range()).unwrap_or(""), &group, &s.clipboard_text)
find_pattern::expand(pc, found, &group, &s.clipboard_text, quotes)
});
out.push(Found { a, b, rep });
let keep = smart && rep.as_deref().is_some_and(|r| find_pattern::already_curled(found, r));
let stays = if keep { found } else { rep.as_deref().unwrap_or(found) };
last = Some((m.end(), stays.chars().next_back().or(before)));
out.push(Found { a, b, rep, keep });
if out.len() >= 100_000 {
return Ok(out);
}
@@ -779,7 +807,8 @@ fn replace(s: &mut Session, v: &Value) -> CmdResult {
// Replace the current match if selected, then move to the next. The result says which
// happened (#6877): a first call that only selects a match reads as `replaced: 0`.
let mut replaced = 0;
if let Some(f) = results.into_iter().find(|f| f.a == a && f.b == b) {
// A match already curled as the replacement would curl it is left as it is (#7307).
if let Some(f) = results.into_iter().find(|f| f.a == a && f.b == b && !f.keep) {
super::paste_text(s, &f.rep.unwrap_or_default())?;
replaced = 1;
}
@@ -799,10 +828,11 @@ fn replace_all(s: &mut Session, v: &Value) -> CmdResult {
need_query(s, v)?;
read_opts(s, v);
let story = s.sel.focus.story;
let results = search_full(s, story, true)?;
// Matches already curled as the replacement would curl them are left and not counted (#7307).
let results: Vec<Found> = search_matches(s, story, true, true)?.into_iter().filter(|f| !f.keep).collect();
let n = results.len();
super::controls::check_deletions(s, story, results.iter().map(|f| (&f.a, &f.b)))?;
for Found { a, b, rep } in results.into_iter().rev() {
for Found { a, b, rep, .. } in results.into_iter().rev() {
let with = rep.unwrap_or_default();
if s.doc.settings.track_changes {
// Same path as a single replace, so the change is a reviewable revision.
+88 -2
View File
@@ -359,6 +359,20 @@ pub enum Piece {
Named(String),
/// `^c`: the clipboard.
Clip,
/// A straight `"` or `'` typed as itself (not a regex, not with special characters off, which
/// takes the text as written, and not given by its code such as `^034`): curled with smart
/// quotes on, as typing curls it ([`Quotes`]).
Quote(char),
}
/// How a quote typed in Replace with goes in (#7307).
#[derive(Clone, Copy, Debug)]
pub enum Quotes {
/// As typed.
Straight,
/// Curled by the typing rule ("straight quotes with smart quotes"): `before` is the character
/// in front of the match, `None` at a paragraph's start.
Smart { before: Option<char> },
}
/// Read Replace with text: `^` codes (unless `literal`), `\1`–`\9` with wildcards, and with a
@@ -438,6 +452,11 @@ pub fn parse_replace(with: &str, o: &Opts) -> Vec<Piece> {
i += used;
continue;
}
if matches!(c, '"' | '\'') && !o.regex {
flush_literal(&mut cur, &mut out);
out.push(Piece::Quote(c));
continue;
}
cur.push(c);
}
flush_literal(&mut cur, &mut out);
@@ -511,7 +530,8 @@ fn as_inserted(s: &str) -> String {
}
/// Fill in Replace with text for one match: `found` is the matched text, `group(n)` a group's.
pub fn expand(pieces: &[Piece], found: &str, group: &dyn Fn(usize) -> Option<String>, clip: &str) -> String {
/// A typed quote is curled by what goes in before it: the replacement so far, else `before`.
pub fn expand(pieces: &[Piece], found: &str, group: &dyn Fn(usize) -> Option<String>, clip: &str, quotes: Quotes) -> String {
let mut out = String::new();
for p in pieces {
match p {
@@ -520,11 +540,39 @@ pub fn expand(pieces: &[Piece], found: &str, group: &dyn Fn(usize) -> Option<Str
Piece::Group(n) => out.push_str(&as_inserted(&group(*n).unwrap_or_default())),
Piece::Clip => out.push_str(&clip.replace("\r\n", "\r").replace('\n', "\r")),
Piece::Named(_) => {}
Piece::Quote(q) => {
let curly = match quotes {
Quotes::Smart { before } => super::text::smart_quote(out.chars().next_back().or(before), *q),
Quotes::Straight => None,
};
match curly {
Some(c) => out.push_str(c),
None => out.push(*q),
}
}
}
}
out
}
/// Whether Replace with has a quote typed as itself, which smart quotes curl.
pub fn has_typed_quote(pieces: &[Piece]) -> bool {
pieces.iter().any(|p| matches!(p, Piece::Quote(_)))
}
/// The match already reads as its replacement: the same text, with a curly quote of the same
/// kind (single or double) wherever the replacement has a curly one. Replace leaves such a match
/// alone and doesn't count it (#7307), so a typed `'` that also finds curly apostrophes keeps one
/// set the other way on purpose (’90s).
pub fn already_curled(found: &str, rep: &str) -> bool {
let kind = |c: char| match c {
'\u{2018}' | '\u{2019}' => Some('\''),
'\u{201C}' | '\u{201D}' => Some('"'),
_ => None,
};
found.chars().count() == rep.chars().count() && found.chars().zip(rep.chars()).all(|(f, r)| f == r || (kind(f).is_some() && kind(f) == kind(r)))
}
#[cfg(test)]
mod tests {
use super::*;
@@ -535,7 +583,45 @@ mod tests {
}
fn replaced(with: &str) -> String {
expand(&parse_replace(with, &Opts::default()), "", &|_| None, "")
expand(&parse_replace(with, &Opts::default()), "", &|_| None, "", Quotes::Straight)
}
fn curled(with: &str, o: &Opts, before: Option<char>) -> String {
expand(&parse_replace(with, o), "", &|_| None, "", Quotes::Smart { before })
}
#[test]
fn a_typed_quote_curls_by_what_goes_before_it_and_a_coded_one_stays_straight() {
let o = Opts::default();
// Opening at a paragraph's start or after a space, closing after a letter.
assert_eq!(curled("\"", &o, None), "\u{201C}");
assert_eq!(curled("\"", &o, Some(' ')), "\u{201C}");
assert_eq!(curled("\"", &o, Some('d')), "\u{201D}");
assert_eq!(curled("'", &o, Some('n')), "\u{2019}");
// Inside the replacement, the text before it decides.
assert_eq!(curled("\"quoted\"", &o, Some(' ')), "\u{201C}quoted\u{201D}");
assert_eq!(curled(" 'a'", &o, Some('x')), " \u{2018}a\u{2019}");
assert_eq!(curled("^p\"", &o, Some('x')), "\r\u{201C}");
// Given by its code, a quote stays straight; with smart quotes off, typed ones do too.
for code in ["^034", "^039", "^u34", "^0039"] {
let straight = if code.ends_with("34") { "\"" } else { "'" };
assert_eq!(curled(code, &o, Some('x')), straight, "{code}");
}
assert_eq!(replaced("\"a'"), "\"a'");
// A regex replacement and an escaped wildcard one are taken as written.
assert_eq!(curled("\"", &Opts { regex: true, ..o }, None), "\"");
assert_eq!(curled("\\\"", &Opts { wildcards: true, ..o }, None), "\"");
assert_eq!(curled("\"", &Opts { wildcards: true, ..o }, None), "\u{201C}");
}
#[test]
fn a_match_already_curled_the_same_kind_reads_as_its_replacement() {
assert!(already_curled("\u{2019}", "\u{2018}"));
assert!(already_curled("don\u{2019}t", "don\u{2019}t"));
assert!(already_curled("\u{201C}", "\u{201D}"));
assert!(!already_curled("'", "\u{2019}"), "a straight quote is curled");
assert!(!already_curled("\u{2019}", "\u{201D}"), "a single quote isn't a double one");
assert!(!already_curled("dont", "don\u{2019}t"));
}
#[test]
+1
View File
@@ -14,6 +14,7 @@ mod enter_tab;
mod unicode;
use autoformat::insert;
pub(crate) use autoformat::smart_quote;
use delete::{backspace, delete, delete_sentence_back, delete_word_back, delete_word_fwd};
pub use enter_tab::MAX_TYPED_PARAGRAPHS;
use enter_tab::{back_tab, new_paragraph, tab};
+9 -3
View File
@@ -17,7 +17,13 @@ fn autoformat(s: &mut Session, text: &str) -> Option<String> {
let f = &s.sel.focus;
let para = s.doc.para_at(f)?;
let before = para.text.get(..f.off)?;
let prev = before.chars().next_back();
smart_quote(before.chars().next_back(), c).map(String::from)
}
/// The curly form of a straight quote `c` that follows `prev` (`None` at a paragraph's start):
/// opening after a space, an opening bracket, a dash or the other opening quote, else closing.
/// A quote typed in Replace with goes in by the same rule (#7307).
pub(crate) fn smart_quote(prev: Option<char>, c: char) -> Option<&'static str> {
let opening = prev.is_none_or(|p| {
p.is_whitespace()
|| "([{<\u{2014}\u{2013}\u{00AB}\u{2039}\u{201E}\u{201A}".contains(p)
@@ -25,8 +31,8 @@ fn autoformat(s: &mut Session, text: &str) -> Option<String> {
|| (c == '\'' && p == '\u{201C}')
});
match c {
'"' => Some(if opening { "\u{201C}" } else { "\u{201D}" }.into()),
'\'' => Some(if opening { "\u{2018}" } else { "\u{2019}" }.into()),
'"' => Some(if opening { "\u{201C}" } else { "\u{201D}" }),
'\'' => Some(if opening { "\u{2018}" } else { "\u{2019}" }),
_ => None,
}
}
@@ -92,3 +92,91 @@ fn normal_double_quote_search_keeps_exact_modes_and_original_byte_ranges() {
run(&mut s, "edit.undo", json!({}));
assert_eq!(text(&s), original);
}
/// #7307: with smart quotes on, a quote typed in Replace with goes in curly by the character
/// before the match, as typing curls it, so finding a straight quote and replacing it with a
/// typed one curls a manuscript's stray quotes in bulk.
#[test]
fn a_quote_typed_in_replace_with_is_curled_by_smart_quotes() {
let mut s = s();
run(&mut s, "document.setText", json!({"text": "He said \"hi\" (\"no\") and 'bye' -- don't"}));
assert_eq!(run(&mut s, "edit.replaceAll", json!({"text": "^034", "with": "\""}))["replaced"], 4);
assert_eq!(text(&s), "He said “hi” (“no”) and 'bye' -- don't");
assert_eq!(run(&mut s, "edit.replaceAll", json!({"text": "^039", "with": "'"}))["replaced"], 3);
assert_eq!(text(&s), "He said “hi” (“no”) and ‘bye’ -- don’t");
// One undo step each.
run(&mut s, "edit.undo", json!({}));
assert_eq!(text(&s), "He said “hi” (“no”) and 'bye' -- don't");
// A match touching the one before it curls by that one's replacement: after an opening
// double quote a single quote opens too.
let mut s = super::s();
run(&mut s, "document.setText", json!({"text": "xx"}));
assert_eq!(run(&mut s, "edit.replaceAll", json!({"text": "x", "with": "'\""}))["replaced"], 2);
assert_eq!(text(&s), "‘“‘“");
// Replace (one at a time) changes only the selected match, so the text before it as it is
// decides: the second `x` follows an unreplaced `x` and closes.
let mut s = super::s();
run(&mut s, "document.setText", json!({"text": "xx"}));
run(&mut s, "select.range", json!({"anchor": wordcraft_doc::Pos::body(0, 1), "focus": wordcraft_doc::Pos::body(0, 2)}));
assert_eq!(run(&mut s, "edit.replace", json!({"text": "x", "with": "'\""}))["replaced"], 1);
assert_eq!(text(&s), "x’”");
}
/// #7307: a typed `'` in Find what also finds curly apostrophes. A match that already is a curly
/// quote of that kind is left as it is and not counted, so an apostrophe set on purpose (’90s)
/// isn't turned into an opening quote.
#[test]
fn replace_with_a_typed_quote_leaves_curly_ones_and_does_not_count_them() {
let mut s = s();
run(&mut s, "document.setText", json!({"text": "the ’90s, it’s 'x' and “y”"}));
assert_eq!(run(&mut s, "edit.replaceAll", json!({"text": "'", "with": "'"}))["replaced"], 2);
assert_eq!(text(&s), "the ’90s, it’s ‘x’ and “y”");
assert_eq!(run(&mut s, "edit.replaceAll", json!({"text": "\"", "with": "\""}))["replaced"], 0);
assert_eq!(text(&s), "the ’90s, it’s ‘x’ and “y”");
// A whole word with its apostrophe: already curled, left alone; straight, curled.
run(&mut s, "document.setText", json!({"text": "don’t don't"}));
assert_eq!(run(&mut s, "edit.replaceAll", json!({"text": "don't", "with": "don't"}))["replaced"], 1);
assert_eq!(text(&s), "don’t don’t");
// Replace (one at a time) skips such a match too, and moves on to the next.
let mut s = super::s();
run(&mut s, "document.setText", json!({"text": "it’s 'x"}));
let first = run(&mut s, "edit.replace", json!({"text": "'", "with": "'"}));
assert_eq!(first["replaced"], 0, "the first call selects the first match");
let kept = run(&mut s, "edit.replace", json!({}));
assert_eq!((kept["replaced"].clone(), text(&s)), (json!(0), "it’s 'x".to_string()), "the curly apostrophe stays");
assert_eq!(run(&mut s, "edit.replace", json!({}))["replaced"], 1);
assert_eq!(text(&s), "it’s ‘x");
}
/// #7307: a quote given by its code stays straight, so curly quotes can still be made straight on
/// purpose; with smart quotes off, or with a regular expression, a typed quote stays straight too.
#[test]
fn coded_quotes_and_smart_quotes_off_replace_with_straight_quotes() {
let mut s = s();
run(&mut s, "document.setText", json!({"text": "“hi” it’s"}));
assert_eq!(run(&mut s, "edit.replaceAll", json!({"text": "\"", "with": "^034"}))["replaced"], 2);
assert_eq!(run(&mut s, "edit.replaceAll", json!({"text": "'", "with": "^039"}))["replaced"], 1);
assert_eq!(text(&s), "\"hi\" it's");
let mut s = super::s();
run(&mut s, "document.setText", json!({"text": "“hi”"}));
assert_eq!(run(&mut s, "edit.replaceAll", json!({"text": "\"", "with": "\"", "regex": false, "wildcards": false}))["replaced"], 0);
assert_eq!(run(&mut s, "edit.replaceAll", json!({"text": "[“”]", "with": "\"", "regex": true}))["replaced"], 2);
assert_eq!(text(&s), "\"hi\"");
// Special characters off takes Replace with as written: with codes off it is the way, besides
// turning smart quotes off, to put a straight quote in.
let mut s = super::s();
run(&mut s, "document.setText", json!({"text": "“hi”"}));
assert_eq!(run(&mut s, "edit.replaceAll", json!({"text": "“", "with": "\"", "special": false}))["replaced"], 1);
assert_eq!(text(&s), "\"hi”");
let mut s = super::s();
s.prefs.autocorrect.smart_quotes = false;
run(&mut s, "document.setText", json!({"text": "“hi”"}));
assert_eq!(run(&mut s, "edit.replaceAll", json!({"text": "\"", "with": "\"", "regex": false}))["replaced"], 2);
assert_eq!(text(&s), "\"hi\"");
}
+5 -1
View File
@@ -1,6 +1,6 @@
# Typing parity with Word
> **Last reviewed:** 2026-10-11 · **Last updated:** 2026-11-17 · **Change:** trivial (formatting carried by Backspace is dropped by a paste, Find, Go To or a click elsewhere too, not only by the caret keys, and kept by an empty paste or a refused command, and carried with Track Changes on too; Find and Track Changes observed in Word for Windows, #6518); previously trivial (Enter in a paragraph with a drop cap makes a normal paragraph, #6788); previously trivial (Ctrl/Cmd+Shift+V pastes the formatting picked up with Ctrl/Cmd+Shift+C or the Format Painter, or text only when none was, #1537); previously trivial (typing after Backspace takes the deleted character's formatting until the caret moves, observed in Word for Windows, #6518; readiness estimates unchanged); previously minor (#3693: additional Delete Previous Sentence command and shortcut; Word-parity estimates unchanged); previously trivial (Ctrl+K on a selection retypes it with a changed Text to display); previously trivial (equation `\int` + Space waits for its limits, `_x^y` then Space builds them and typing goes into the operand, and any character that can't continue `\name` corrects it, observed in Word for Windows on #4938, #4917); previously minor (English spelling by dialect from SCOWL 2026, CP2; previously trivial: a tracked heading or border-line AutoFormat replaces another author's formatting change; previously trivial: Relative font-size commands preserve mixed sizes in the selection (#4903); existing button steps and one-point shortcuts are unchanged; readiness estimates unchanged); previously trivial (highlight at a caret leaves the word alone, #4086); previously trivial (Arabic Backspace removes one combining mark and keeps its base letter (#4757); previously trivial: tests and notes for the border-line, table, tab-indent and wide-space rules; previously trivial: `*Bold* and _italic_ as real formatting` in AutoFormat As You Type; previously trivial: highlight target includes selected paragraph marks, #4085; previously trivial: full-target highlight check beyond 10,000 runs, #4085; previously trivial: queued IME replacements are rejected before mutation after their marked composition loses its body/equation target; previously trivial: the transactional equation delete proves its commit with the engine revision; previously trivial: a refused byte-counted equation deletion drops only the immediately adjacent stale replacement, so a later direct commit still applies; previously trivial: a tracked own-insertion shifts the rest of a two-sided IME deletion; previously trivial: AutoCorrect/AutoFormat classification compares the actual paragraph; previously trivial: a replaced body starts a new input-method context and interrupts the composition; a quote the engine leaves as typed is the input method's own change; equation `DeleteSurrounding` erases counted characters; previously trivial: AutoCorrect finds the word after a no-break space or an ideographic space; previously trivial: a command that changes nothing is not an edit: no undo step, no unsaved changes, no relayout, and the redo stack survives it; previously trivial: while an input method composes, the caret and its candidate window sit at the input method's cursor inside the composition; previously trivial: Ctrl+Tab types a tab in a table cell, #3137; previously trivial: List AutoFormat triggers in front of an already-written paragraph, not only a fresh empty one, checked in Word for Windows, #3352; previously trivial: AltGr types its characters without opening KeyTips on Linux, #2388; previously trivial: Delete on whole selected cells leaves one empty paragraph in each, with the cell's last paragraph's formatting; nested tables go too, #2802; previously trivial: Bullets and Numbering toggle off style-inherited lists at their effective level, including basedOn chains and numbered ListParagraph styles; other paragraphs and list definitions stay unchanged (related to #3459); previously trivial: a text box that keeps the keyboard no longer resets the input method every frame, #2986; previously trivial: a slash opening a word travels whole to the next line, #2963; previously trivial: typing over a selection takes the first selected character's formatting, also when the selection was made right to left, #2879; previously trivial: Turkish and Azerbaijani case mapping in AutoCorrect, #1923; previously trivial: smart quotes in Hebrew pinned: logical order, ” in acronyms as in Word, #1670; previously trivial: Backspace on a selected table, rows or columns deletes them, Delete clears them, #1844; previously trivial: typed text takes its direction from its own letters, #1543; previously trivial: an input method's request to erase text around the caret is honoured, so web typing in Cyrillic and other non-Latin text no longer repeats, #1480; previously trivial: `-->` AutoCorrect replacement, #2223; previously trivial: a heading-list preset keeps Heading styles and makes other paragraphs Heading Line truncated
> **Last reviewed:** 2026-10-11 · **Last updated:** 2026-11-27 · **Change:** trivial (a quote typed in Replace with goes in curly by the typing rule when smart quotes are on; coded quotes stay straight; matches already curled the same kind are left and not counted, #7307); previously trivial (formatting carried by Backspace is dropped by a paste, Find, Go To or a click elsewhere too, not only by the caret keys, and kept by an empty paste or a refused command, and carried with Track Changes on too; Find and Track Changes observed in Word for Windows, #6518); previously trivial (Enter in a paragraph with a drop cap makes a normal paragraph, #6788); previously trivial (Ctrl/Cmd+Shift+V pastes the formatting picked up with Ctrl/Cmd+Shift+C or the Format Painter, or text only when none was, #1537); previously trivial (typing after Backspace takes the deleted character's formatting until the caret moves, observed in Word for Windows, #6518; readiness estimates unchanged); previously minor (#3693: additional Delete Previous Sentence command and shortcut; Word-parity estimates unchanged); previously trivial (Ctrl+K on a selection retypes it with a changed Text to display); previously trivial (equation `\int` + Space waits for its limits, `_x^y` then Space builds them and typing goes into the operand, and any character that can't continue `\name` corrects it, observed in Word for Windows on #4938, #4917); previously minor (English spelling by dialect from SCOWL 2026, CP2; previously trivial: a tracked heading or border-line AutoFormat replaces another author's formatting change; previously trivial: Relative font-size commands preserve mixed sizes in the selection (#4903); existing button steps and one-point shortcuts are unchanged; readiness estimates unchanged); previously trivial (highlight at a caret leaves the word alone, #4086); previously trivial (Arabic Backspace removes one combining mark and keeps its base letter (#4757); previously trivial: tests and notes for the border-line, table, tab-indent and wide-space rules; previously trivial: `*Bold* and _italic_ as real formatting` in AutoFormat As You Type; previously trivial: highlight target includes selected paragraph marks, #4085; previously trivial: full-target highlight check beyond 10,000 runs, #4085; previously trivial: queued IME replacements are rejected before mutation after their marked composition loses its body/equation target; previously trivial: the transactional equation delete proves its commit with the engine revision; previously trivial: a refused byte-counted equation deletion drops only the immediately adjacent stale replacement, so a later direct commit still applies; previously trivial: a tracked own-insertion shifts the rest of a two-sided IME deletion; previously trivial: AutoCorrect/AutoFormat classification compares the actual paragraph; previously trivial: a replaced body starts a new input-method context and interrupts the composition; a quote the engine leaves as typed is the input method's own change; equation `DeleteSurrounding` erases counted characters; previously trivial: AutoCorrect finds the word after a no-break space or an ideographic space; previously trivial: a command that changes nothing is not an edit: no undo step, no unsaved changes, no relayout, and the redo stack survives it; previously trivial: while an input method composes, the caret and its candidate window sit at the input method's cursor inside the composition; previously trivial: Ctrl+Tab types a tab in a table cell, #3137; previously trivial: List AutoFormat triggers in front of an already-written paragraph, not only a fresh empty one, checked in Word for Windows, #3352; previously trivial: AltGr types its characters without opening KeyTips on Linux, #2388; previously trivial: Delete on whole selected cells leaves one empty paragraph in each, with the cell's last paragraph's formatting; nested tables go too, #2802; previously trivial: Bullets and Numbering toggle off style-inherited lists at their effective level, including basedOn chains and numbered ListParagraph styles; other paragraphs and list definitions stay unchanged (related to #3459); previously trivial: a text box that keeps the keyboard no longer resets the input method every frame, #2986; previously trivial: a slash opening a word travels whole to the next line, #2963; previously trivial: typing over a selection takes the first selected character's formatting, also when the selection was made right to left, #2879; previously trivial: Turkish and Azerbaijani case mapping in AutoCorrect, #1923; previously trivial: smart quotes in Hebrew pinned: logical order, ” in acronyms as in Word, #1670; previously trivial: Backspace on a selected table, rows or columns deletes them, Delete clears them, #1844; previously trivial: typed text takes its direction from its own letters, #1543; previously trivial: an input method's request to erase text around the caret is honoured, so web typing in CyrillicLine truncated
What Word does when you type, observed black-box (same keystrokes typed into Word and
WordCraft, results read back paragraph by paragraph) and pinned by tests in
@@ -29,6 +29,9 @@ Evidence: `crates/engine/src/tests/typing.rs::delete_previous_sentence_respects_
Ordinary Find and Replace treat a keyboard apostrophe (`'`) as a straight or typographic single quote (`‘`, `’`), so a search for `Tau'va` finds `Tau’va` typed with smart quotes. Partial queries, case options and whole-word matching still apply. Wildcards, regular expressions, literal searches (`special: false`) and numeric character codes such as `^u39` remain exact. A curly-quote query also stays exact, and the modifier-letter apostrophe `ʼ` is distinct. Replacement `^&` keeps the original matched spelling. This behavior is covered by original engine and CLI/MCP controls; no fresh Word or native desktop comparison is claimed.
## Replacing with a typed quote (#7307)
With AutoFormat As You Type's "straight quotes with smart quotes" on, a `"` or `'` typed in Replace with goes in curly, by the same rule as typing: opening at a paragraph's start or after a space, an opening bracket, a dash or the other opening quote, closing otherwise. The character before the match decides, or the replacement's own text before the quote, or, in Replace All, the previous match's replacement when the two touch (Replace, one at a time, reads the text as it is). So finding `^034` and replacing with a typed `"` curls a manuscript's stray straight quotes in bulk. A quote given by its code (`^034`, `^039`, `^u34`), or escaped in a wildcard replacement (`\"`), stays straight, so curly quotes can still be made straight on purpose; with smart quotes off, in a regular-expression replacement, or with special characters off (`special: false`, which takes Replace with as written), a typed quote stays straight too. A typed `'` in Find what also finds curly apostrophes: a match that already reads as the replacement with a curly quote of the same kind (single or double) is left as it is and not counted, so an apostrophe set on purpose (`’90s`) doesn't become an opening quote. The issue reports this behaviour in Word; it is pinned by engine tests (`tests/find_apostrophes.rs`) and not compared with Word again here. Typing an apostrophe before a year's short form or a clipped word is not handled.
## Highlight shortcut (#4085)
@@ -622,6 +625,7 @@ DOCX and Undo/Redo (Leaf #152). No new Word or native UI comparison was run.
| Date | Change | Summary |
|---|---|---|
| 2026-11-27 | trivial | Replace with: a typed `"` or `'` goes in curly by the typing rule when smart quotes are on; `^034`/`^039` stay straight; a match that already is a curly quote of that kind is left and not counted (#7307) |
| 2026-11-17 | trivial | Backspace, then type: the carried formatting is dropped by a paste (whose text never takes it), Find, Go To or a click elsewhere (also one back to the same place), not only by the caret keys; an empty paste or a refused command keeps it; it follows typing and comes back with Undo; with Track Changes on it carries too, as in Word for Windows, and the typed text is a tracked insertion (#6518) |
| 2026-11-15 | trivial | Enter in a paragraph with a drop cap: the new paragraph gets no drop cap (#6788); synthetic coverage, offset 0 unchanged and not compared with Word |
| 2026-11-15 | trivial | Paste Formatting row: Ctrl/Cmd+Shift+V pastes the picked-up formatting, else text only; Ctrl/Cmd+Shift+C no longer arms the Format Painter (#1537, #4943); the chord's V release never pastes again (Shift up first); web text paste relies on the browser sending its paired Paste event, and the formatting paste drops that event only within about a second |