mirror of
https://github.com/storytold/gridcraft.git
synced 2026-11-05 01:58:58 +00:00
Point mode: keep the sheet qualifier when pointing with the arrow keys
point_move wrote a bare reference, so on another sheet Shift+arrow after a header drag turned 'Other sheet'!B:D into B:E, which reads as the formula's own sheet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b3bce6cc81
commit
d976bbdcba
2 files changed
+17
No files matched your search
@@ -1096,6 +1096,7 @@ pub fn point_move(app: &mut SheetApp, ed: &mut EditState, dr: i64, dc: i64, exte
|
||||
to
|
||||
};
|
||||
let text = if extend { RangeRef::new(anchor, to).a1() } else { to.a1() };
|
||||
let text = if ed.sheet != d.wb.active_sheet() { format!("{}!{text}", gridcraft_engine::formula::quote_sheet(&sheet.name)) } else { text };
|
||||
let sheet = d.wb.active_sheet();
|
||||
ed.insert_ref(&text);
|
||||
ed.point_cell = Some(to);
|
||||
|
||||
@@ -302,3 +302,19 @@ fn shift_arrow_after_a_header_drag_moves_the_dragged_end() {
|
||||
shift_arrow(&mut h, egui::Key::ArrowDown);
|
||||
assert_eq!(text(&h), "=SUM(1:4");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn shift_arrow_pointing_on_another_sheet_keeps_the_qualifier() {
|
||||
let mut h = harness();
|
||||
h.state_mut().session.execute("home.insertSheet", json!({"name": "Other sheet"})).unwrap();
|
||||
h.run_steps(2);
|
||||
let (b, d) = (header_center(&h, false, 1), header_center(&h, false, 3));
|
||||
press_and_drag(&mut h, b, d, Modifiers::NONE);
|
||||
release(&mut h, d);
|
||||
assert_eq!(text(&h), "=SUM('Other sheet'!B:D");
|
||||
let app = h.state_mut();
|
||||
let mut ed = app.editor.take().unwrap();
|
||||
gridcraft_ui_egui::grid::point_move(app, &mut ed, 0, 1, true, false);
|
||||
app.editor = Some(ed);
|
||||
assert_eq!(text(&h), "=SUM('Other sheet'!B:E");
|
||||
}
|
||||
Reference in new issue
Block a user