Repository navigation
Drag and drop asks before replacing data (fixes #3136) - #3216
Conversation
Dragging the selection's border onto cells that hold data replaced them
without asking, so dragging column B onto column A silently destroyed A.
Excel asks "There's already data here. Do you want to replace it?" first
(its "Alert before overwriting cells" option, on by default).
The drop now runs a new `range.move {range?, to, overwrite?}` command:
a cut and paste that returns a confirm question when the destination
holds data other than the moved cells; the grid shows it with OK and
Cancel, and OK runs it again with `overwrite: true`. A refused move
leaves the sheet and the clipboard as they were.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 16 minutes. View limit details
Walkthrough
Merge Risk:
|
…e replacing spilled values Addresses CodeRabbit review on storytold#3216: - "Pass the resolved sheet to the paste step": a sheet-qualified move (`Two!B1:B2` with Sheet1 active) was checked on Two but pasted on the active sheet, replacing its data unasked. range.move now calls paste_special with the range's sheet. - "Check spilled values in the drop destination": cells showing a dynamic array's spilled values hold no cell of their own, so the drop replaced them without the prompt. They now count as data, as in Excel (ISBLANK of a spill cell is FALSE, COUNTA counts it). Tests: drag_and_drop_on_another_sheet_stays_on_that_sheet, drag_and_drop_asks_before_replacing_spilled_values. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
About the Linked Issues pre-merge warning (the issue asks for column B to swap places with column A): a plain border drag in Excel doesn't swap. It asks "There's already data here. Do you want to replace it?" and replaces on OK, which is what this PR adds. The swap the reporter wants is Excel's Shift+drag (insert between columns). The PR description already lists that as a follow-up, so I'm keeping this PR to the data-loss part. I'm leaving the docstring coverage warning as is, because |
…ction Addresses CodeRabbit review on storytold#3216, "Keep the selection on the sheet it describes": moving Two!B1:B2 with Sheet1 active selected A1:A2 on Sheet1, where nothing moved. The selection belongs to the active sheet, so range.move now keeps it when the moved cells are on another sheet; a move on the active sheet still selects the moved cells. Test: drag_and_drop_on_another_sheet_stays_on_that_sheet (now also checks the selection). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Merged — thank you @hectorviov for the contribution! |
Fixes #3136
What
Dragging a selection by its border onto cells that hold data replaced them without asking, so dragging column B onto column A silently destroyed column A. Excel asks first: "There's already data here. Do you want to replace it?" (its Alert before overwriting cells option, on by default). GridCraft now asks the same question, with OK and Cancel.
range.move {range?, to, overwrite?}(label "Drag and Drop", one undo step): the same cut and paste the drop ran before, but when the destination holds content outside the moved cells it returns a confirm question (EngineError::Confirm) instead of moving.overwrite: truegoes ahead. A refused or failed move leaves the sheet and the clipboard as they were (a copy made earlier keeps its marching ants).crates/ui-egui/src/grid/interact.rs) runsrange.movethroughmacro_ui::call, so the existing question box shows the question; OK runs it again withoverwrite: true, Cancel does nothing.docs/ui-parity.md: the drag-move row claimed Ctrl/Option copy and Shift insert were done for the border drag; they are not wired (the drop ignores modifiers), so the row now says so, plus a revision row.Comparison
Synthetic workbook: A1:B3 = Apple/Kiwi, Pear/Plum, Fig/Lime. Select column B, drag its border onto column A.
Tests
cmd::edit::tests::drag_and_drop_asks_before_replacing_data(engine): the question, nothing moved and the earlier copy kept on refusal,overwrite: truereplaces, no question onto empty cells or onto the moved cells' own place,torequired.drag_cursor::moving_a_selection_onto_data_asks_before_replacing_it(ui-egui, real pointer input): the drop asks, nothing changes until Enter (OK), then the cells move.cargo xtask cipasses.Anything a reviewer should look at first
Cell::has_content); formatting alone doesn't ask. Cells inside the moved range itself never ask.sheet.moveColumns).🤖 Generated with Claude Code
Summary by CodeRabbit