Skip to content

Formulas: F3 opens Paste Name, which inserts a defined name or pastes the list of names - #2410

Merged
aiongg merged 1 commit into
storytold:mainfrom
dotCooCoo:feat/paste-names
Oct 25, 2026
Merged

aiongg merged 1 commit into
storytold:mainfrom
dotCooCoo:feat/paste-names

Conversation

@dotCooCoo

@dotCooCoo dotCooCoo commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

GridCraft had no Paste Name dialog: F3 did nothing, Alt+M, S, P was a reserved key tip, and Formulas › Use in Formula had no Paste Names… item. In Excel, F3 "displays the Paste Name dialog box. Available only if names have been defined in the workbook" (Keyboard shortcuts in Excel), and the dialog's Paste List button produces "two columns in the spreadsheet" holding the "range names and the cell references that each range holds" (Insert a named range into a formula in Excel).

Changes

  • New command formulas.pasteName (Formulas › Defined Names, F3). It returns the names the dialog lists: the workbook's names and the active sheet's own, without hidden names, in alphabetical order. {name} puts the name at the caret of the formula being edited, in place of selected text, or starts =Name in the active cell. {list: true, at?} writes each name and the text of what it refers to in two columns from the active cell as one undo step, and keeps the cells' formats. It returns an error when there are no names or the list does not fit on the sheet.
  • The Paste Name dialog opens from F3 when the workbook has names, from a new Paste Names… item at the end of Use in Formula, and from Alt+M, S, P. OK, Enter or a double-click inserts the selected name, Up and Down move through the list, and ui.dialog.confirm runs the same command. Paste List is disabled while a cell is being edited.
  • F3 also opens the dialog from the cell editor and the formula bar. While a dialog is open over the edit, the editor takes no keys, so typing and arrows do not change the formula being edited. Cancel leaves the text that was selected before the dialog opened selected.
  • Use in Formula lists the same names. formulas.useInFormula now inserts at the caret: it used to replace the text being edited with =Name, and the menu used to list hidden names and other sheets' names.
  • In keytips.json, MSP opens the dialog. generated.rs and tests/it/keytips_generated.rs were regenerated with cargo xtask keytips.
  • docs/ui-parity.md gets the F3 entries in the F-key rows, a new F3 row (the Mac column says "not checked"), the header's Last updated date and Change list, and a revision history row.

The pages do not give the list's order, which names it leaves out, or what Paste List writes into the cells. GridCraft's own rules: the names are in alphabetical order, the list holds the workbook's names and the active sheet's own (a sheet name hides the workbook name it shares) and leaves out hidden names, and Paste List writes the refers-to column as text and keeps the cells' formats. Up and Down, double-click, and Paste List being disabled during an edit are GridCraft's own behavior too.

Tests

  • paste_names_lists_the_names_the_active_sheet_can_use checks the order, that a sheet name hides the workbook name it shares, and that hidden names and other sheets' names are left out. On main, formulas.pasteName is an unknown command.
  • paste_names_and_use_in_formula_ask_the_ui_to_insert_the_name checks that both commands send InsertName. InsertName does not exist on main.
  • paste_list_writes_each_name_and_what_it_refers_to checks the two text columns, that one Undo removes them, and at. It fails on main.
  • paste_list_needs_names_and_room checks that Paste List returns an error when three names start on the second-to-last row, when they start in the last column, and when the workbook has no names. It fails on main.
  • editor::tests::a_pasted_name_replaces_the_selected_text checks that the selection is replaced and a stale function suggestion is cleared. It does not compile on main.
  • tests/it/paste_names.rs has 7 egui_kittest tests: F3 with and without names, OK, Up/Down, ui.dialog.confirm, F3 in the cell editor with typing locked out, Cancel keeping the selected text selected, and Paste List. On main F3 opens no dialog, so all seven fail.

Before the gate, these targeted checks were run: cargo fmt --all -- --check, cargo clippy -p gridcraft-engine -p gridcraft-ui-egui --all-targets -- -D warnings, cargo test -p gridcraft-engine, cargo test -p gridcraft-ui-egui, cargo xtask keytips --check, cargo xtask assets and cargo xtask layers. cargo test -p gridcraft-ui-egui had one failure, header_autofit::table_filter_autofit_works_through_command_and_header_double_click, which also fails on main at 72c1d57 on this machine.

Checks

On Windows 11 (x86-64) with rustc 1.99.1, on top of main at 72c1d57, with #2273 merged in:

  • cargo xtask ci passes its 10 steps: 2,280 tests passed, 0 failed, 1 ignored.

#2273 fixes header_autofit::table_filter_autofit_works_through_command_and_header_double_click, which fails on main at 72c1d57 on this machine without this branch. Without #2273, cargo xtask ci stops at its test step on that test.

git merge-tree reports no conflicts with main at 72c1d57.

Summary by CodeRabbit

  • New Features
    • Open the Paste Name dialog with F3 or the Formulas tab to browse defined names available in the workbook or active sheet.
    • Choose a name to insert it into the formula at the cursor, replacing selected text when applicable.
    • Paste available names and their references into a two-column cell range.
    • Use the dialog’s keyboard navigation to select a name or cancel.

… the list of names

formulas.pasteName lists the names the active sheet can use (workbook
names and the sheet's own, without hidden names, in alphabetical order).
With name it puts the name at the caret of the formula being edited,
replacing selected text, or starts =Name; with list: true it writes each
name and the text of what it refers to in two columns from the active
cell. The Paste Name dialog opens from F3 when the workbook has names,
from Use in Formula's new Paste Names… item and from Alt+M, S, P. While
a dialog is open over the edit, the editor takes no keys.

Use in Formula lists the same names, and formulas.useInFormula inserts
at the caret instead of replacing the text being edited.
@coderabbitai

coderabbitai Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 72c1d57 and 3557b9f.

Files selected for processing: 15
  • crates/engine/src/cmd/extra.rs
  • crates/engine/src/cmd/formulas.rs
  • crates/engine/src/lib.rs
  • crates/ui-egui/src/dialogs.rs
  • crates/ui-egui/src/editor.rs
  • crates/ui-egui/src/formula_bar.rs
  • crates/ui-egui/src/keymap.rs
  • crates/ui-egui/src/keytips/keytip_table/generated.rs
  • crates/ui-egui/src/keytips/keytips.json
  • crates/ui-egui/src/lib.rs
  • crates/ui-egui/src/ribbon.rs
  • crates/ui-egui/tests/it/keytips_generated.rs
  • crates/ui-egui/tests/it/main.rs
  • crates/ui-egui/tests/it/paste_names.rs
  • docs/ui-parity.md

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.

Walkthrough

Adds a Paste Name dialog for visible workbook and active-sheet names. Users can insert a selected name at the formula caret or start editing with that name. The dialog also supports writing names and their references to two columns.

Changes: Paste Name

Layer / File(s) Summary
Name listing and Paste Names command
crates/engine/src/cmd/formulas.rs
Registers formulas.pasteName, lists visible workbook and active-sheet names, and supports writing names and references to two columns. Engine tests cover name filtering, output, and error cases.
Dialog and caret insertion
crates/engine/src/lib.rs, crates/engine/src/cmd/extra.rs, crates/ui-egui/src/dialogs.rs, crates/ui-egui/src/editor.rs, crates/ui-egui/src/formula_bar.rs, crates/ui-egui/src/lib.rs, crates/ui-egui/tests/it/paste_names.rs, crates/ui-egui/tests/it/main.rs
The dialog supports name selection, confirmation, and Paste List. Insertion replaces selected text or starts editing with =<name>. The formula editor retains its selection while the dialog is open.
Shortcut and ribbon entry points
crates/ui-egui/src/keymap.rs, crates/ui-egui/src/keytips/*, crates/ui-egui/src/ribbon.rs, crates/ui-egui/tests/it/keytips_generated.rs, docs/ui-parity.md
F3, the MSP keytip, and the Formulas ribbon open or invoke Paste Name. The keytip test and UI parity document reflect the updated behavior.

Priority: Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  actor User
  participant PasteNameDialog
  participant formulas.pasteName
  participant SheetApp
  participant dialogs.insert_name
  participant EditState
  User->>PasteNameDialog: Confirm selected name
  PasteNameDialog->>formulas.pasteName: Submit name
  formulas.pasteName->>SheetApp: Return UiRequest::InsertName
  SheetApp->>dialogs.insert_name: Route name request
  dialogs.insert_name->>EditState: Insert at caret when editing
Loading

Possibly related PRs

  • storytold/gridcraft#465: Stores macro data in hidden workbook-scope defined names, which the Paste Name list excludes.
  • storytold/gridcraft#2144: Uses hidden workbook-scope defined names for stash data and macro storage, which the Paste Name list excludes.

Suggested reviewers: marcoarnulfo

Merge Risk: Minimal · up to 3557b

No actionable issue remains in the Paste Name flow; it is ready to merge after normal checks.

Security architecture risk: Low · up to 3557b

The new workflow remains within the active workbook and uses existing protected-cell checks and reversible editing. No introduced security vulnerability was established. Remaining uncertainty concerns compatibility with other consumers and behavior outside the inspected workflow.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The inspected effects are bounded to a pending editor or the active workbook's active sheet. An explicit Paste List destination cannot name a different sheet, and destination bounds are checked before mutation. This trace does not establish cross-tenant, credential, or service-level exposure.

Trust Boundaries and Controls

  • observed — Paste List retains centralized protected-cell enforcement: its transaction does not set protection_checked, so old and new cell contents are checked before the workbook is replaced. Committed editor insertion also passes through cell.set's locked-cell checks.
  • inferred — The normal dialog restricts selection to listed names, but programmatic insertion accepts arbitrary name text. That is not a newly established security bypass: useInFormula already accepted arbitrary text at the base, and the new path still requires ordinary editor commit before worksheet evaluation.

Resilience and Maintainability Implications

  • observed — Paste List closes the dialog after submission, including on command failure, but reports the error through the existing alert path. Transaction failure leaves the original workbook uncommitted, so retry does not resume a partially written list.
Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 27.91% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 43 functions across 13 files. (2 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: F3 opens Paste Name and supports inserting a defined name or pasting the name list.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 27.91% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 43 functions across 13 files. (2 skipped: 2 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants