mirror of
https://github.com/storytold/wordcraft.git
synced 2026-10-29 04:47:10 -06:00
Co-authored-by: Brandon Thomas <echelon@gmail.com>
This commit is contained in:
co-authored by
Brandon Thomas
parent
daf8caada3
commit
4b33e7b4ab
@@ -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`]).
|
||||
|
||||
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user