Skip to content

DesignCraft: An open-source page and layout design editor written by scratch in pure Rust

Tab in footnote text is typed, not taken for the next table cell

moppeeer948482d60fe1
diff --git a/crates/engine/src/cmd/text/edit.rs b/crates/engine/src/cmd/text/edit.rs
index 21888cb22..fd104cbcd 100644
--- a/crates/engine/src/cmd/text/edit.rs
+++ b/crates/engine/src/cmd/text/edit.rs
@@ -13,8 +13,9 @@ fn reserve_command_text(st: &mut designcraft_doc::Story, additional: usize) -> R
pub(super) fn insert(s: &mut Session, p: &Value) -> Result<Value> {
let text = crate::cmd::text_param(p, "text");
- // Tab in a table cell moves to the next cell (Shift-Tab: `table.prevCell`).
- if text == "\t" && s.doc()?.selection.text.is_some_and(|t| t.cell.is_some()) {
+ // Tab in a table cell moves to the next cell (Shift-Tab: `table.prevCell`). Footnote text is
+ // addressed as a cell too: a Tab there is typed.
+ if text == "\t" && s.doc()?.selection.text.is_some_and(|t| t.cell.is_some_and(|c| c.footnote_id().is_none())) {
return crate::cmd::table::step_cell(s, true);
}
// Typing with one cell selected replaces its text, as InDesign.
diff --git a/crates/engine/src/tests/table.rs b/crates/engine/src/tests/table.rs
index c6b2b8824..45e4b8db8 100644
--- a/crates/engine/src/tests/table.rs
+++ b/crates/engine/src/tests/table.rs
@@ -140,6 +140,10 @@ fn the_cell_commands_refuse_footnote_text() {
assert!(s.execute(cmd, &json!({})).is_err(), "{cmd}");
}
assert_eq!(s.doc().unwrap().selection, before);
+ // A Tab there is typed into the footnote, not taken for the next cell.
+ s.execute("text.insert", &json!({"text": "\t"})).unwrap();
+ let notes = s.execute("footnote.list", &json!({})).unwrap();
+ assert!(notes[0]["text"].as_str().is_some_and(|t| t.contains('\t')), "{notes}");
}
/// Esc in a table toggles between the text and the cell (InDesign's Esc): the caret in a cell