From 4b33e7b4ab8edf082be5c8b7adfe2a00d01fb884 Mon Sep 17 00:00:00 2001 From: MarekSpodBiedry <73122968+MarekSpodBiedry@users.noreply.github.com> Date: Thu, 15 Oct 2026 03:59:29 +0200 Subject: [PATCH] Text typed after a footnote or endnote number is no longer superscript (#1593) (#1663) Co-authored-by: Brandon Thomas --- crates/engine/src/session.rs | 7 ++++++- crates/engine/src/tests.rs | 16 ++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/crates/engine/src/session.rs b/crates/engine/src/session.rs index c96ceae03..4f16aea9a 100644 --- a/crates/engine/src/session.rs +++ b/crates/engine/src/session.rs @@ -1321,7 +1321,12 @@ impl Session { // As in Word, text typed at either end of a hyperlink isn't part of it; only typing // inside the link extends it. let inside_link = props.link.is_some() && f.off > 0 && f.off < p.len() && p.props_of_char(f.off).link == props.link; - if props.link.is_some() && !inside_link { props.unlinked() } else { props.clone() } + let mut out = if props.link.is_some() && !inside_link { props.unlinked() } else { props.clone() }; + // A footnote or endnote number is raised by its character style; text typed after it is body text. + if matches!(out.style.as_deref(), Some("FootnoteReference" | "EndnoteReference")) { + out.style = None; + } + out } /// Words in the document, as the status bar shows them (see [`Prefs::count_notes`]). diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs index b96e7f512..72e112823 100644 --- a/crates/engine/src/tests.rs +++ b/crates/engine/src/tests.rs @@ -6638,6 +6638,22 @@ fn exported_page_images_draw_headers_at_full_strength() { let _ = std::fs::remove_dir_all(&dir); } +/// Text typed right after a footnote or endnote number is plain body text, not another raised number. +#[test] +fn typing_after_a_note_number_is_not_superscript() { + for (cmd_id, style) in [("references.footnote", "FootnoteReference"), ("references.endnote", "EndnoteReference")] { + let mut s = s(); + run(&mut s, "text.insert", json!({"text": "One"})); + run(&mut s, cmd_id, json!({"text": "Note"})); + s.sel = crate::Selection::caret(s.doc.end_of(StoryRef::Body)); + assert_eq!(s.doc.para_at(&s.sel.focus).and_then(|p| p.props_at(p.len()).style.clone()).as_deref(), Some(style)); + assert_eq!(s.typing_props().style, None, "{cmd_id}"); + run(&mut s, "text.insert", json!({"text": " after"})); + let end = s.doc.end_of(StoryRef::Body); + assert_eq!(s.doc.para_at(&end).map(|p| p.props_of_char(p.len() - 1).style.clone()), Some(None), "{cmd_id}"); + } +} + /// Gap 19, review: text inserted by one author and deleted by another keeps both marks through /// an ODT save, so Reject All (undo the deletion, then the insertion) and Accept All both remove it. #[test]