diff --git a/crates/ui-egui/src/formula_bar.rs b/crates/ui-egui/src/formula_bar.rs index 848ba5458..8c12c4d9e 100644 --- a/crates/ui-egui/src/formula_bar.rs +++ b/crates/ui-egui/src/formula_bar.rs @@ -325,6 +325,8 @@ pub fn editor_widget(app: &mut SheetApp, ui: &mut egui::Ui, id: egui::Id, font: ed.completion = crate::editor::column_completion(sh, ed.cell, &ed.text); } ed.point = None; + // Typing ends the pointing: the next arrow starts again from the edited cell, as in Excel. + ed.point_cell = None; let names: Vec = function_names() .iter() .map(|name| { diff --git a/crates/ui-egui/tests/selection.rs b/crates/ui-egui/tests/selection.rs index faebebf00..297870808 100644 --- a/crates/ui-egui/tests/selection.rs +++ b/crates/ui-egui/tests/selection.rs @@ -159,3 +159,20 @@ fn formula_point_drag_keeps_the_sheet_qualifier() { h.state_mut().session.execute("sheet.activate", json!({"sheet": "Sheet1"})).unwrap(); assert_eq!(cells(&h), before); } + +#[test] +fn formula_arrow_pointing_restarts_from_the_edited_cell_after_typing() { + let mut h = harness("B4"); + h.state_mut().begin_edit(Some("=".into()), false); + h.run_steps(2); + h.key_press(egui::Key::ArrowUp); + h.run_steps(1); + h.key_press(egui::Key::ArrowUp); + h.run_steps(1); + assert_eq!(h.state().editor.as_ref().unwrap().text, "=B2"); + frame(&mut h, Event::Text("+".into())); + h.run_steps(1); + h.key_press(egui::Key::ArrowUp); + h.run_steps(1); + assert_eq!(h.state().editor.as_ref().unwrap().text, "=B2+B3"); +}