mirror of
https://github.com/storytold/designcraft.git
synced 2026-10-31 21:56:50 -06:00
Integration: #1674 text.move leaves the selected cells, so typing inserts at the caret
This commit is contained in:
@@ -380,6 +380,8 @@ pub(super) fn move_caret(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
s.typing_format = None;
|
||||
let stm = s.doc_mut()?;
|
||||
stm.selection.text = Some(if extend { TextSel { focus: new, ..t } } else { TextSel { anchor: new, focus: new, ..t } });
|
||||
// Moving the caret leaves the selected cells, so typing inserts at the caret.
|
||||
stm.selection.cells = None;
|
||||
stm.bump_revision();
|
||||
Ok(json!({"pos": new}))
|
||||
}
|
||||
|
||||
@@ -176,6 +176,12 @@ fn escape_toggles_text_and_cell_selection() {
|
||||
let sel = s.doc().unwrap().selection.clone();
|
||||
assert!(sel.cells.is_none());
|
||||
assert_eq!(sel.text.unwrap().range(), 3..3);
|
||||
// Moving the caret leaves the cell selection: typing inserts at the caret, not over the cell.
|
||||
s.execute("table.toggleSelection", &json!({})).unwrap();
|
||||
s.execute("text.move", &json!({"dir": "right"})).unwrap();
|
||||
assert!(s.doc().unwrap().selection.cells.is_none());
|
||||
s.execute("text.insert", &json!({"text": "!"})).unwrap();
|
||||
assert_eq!(s.execute("table.get", &json!({"table": tid})).unwrap()["cells"][1]["text"], "F!ax");
|
||||
// A selection that starts inside a merged cell goes back to the merged cell's text.
|
||||
s.execute("table.select", &json!({"rows": [0, 1], "cols": [0, 0]})).unwrap();
|
||||
s.execute("table.merge", &json!({})).unwrap();
|
||||
|
||||
Reference in New Issue
Block a user