Skip to content

fix(edit): Ctrl+Enter gives each cell the number format typing gives it (#1919) - #1920

Merged
h-a-n-a-s-h-i merged 1 commit into
storytold:mainfrom
vedran-dobos:range-fill-formats
Oct 19, 2026
Merged

h-a-n-a-s-h-i merged 1 commit into
storytold:mainfrom
vedran-dobos:range-fill-formats

Conversation

@vedran-dobos

@vedran-dobos vedran-dobos commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1919.

range.fill (Ctrl+Enter) parsed the input once at the active cell, then put each target cell’s old
style back when it already held a cell, so 5%, $5, 3/4/2026 or =DATE(…) lost their
automatic format there (0.05, 5, 46085). Empty targets took the active cell’s style instead of
their own. Now each target gets what input_to_cell gives for that cell, which is what typing the
input there gives.

What changed

  • engine cmd/edit.rs range_fill: the input goes through input_to_cell for each target
    cell, so a General cell gets the automatic format, a cell with its own format (or a formatted row
    or column) keeps it, and a Text cell gets the input as text, as with cell.set. The result only
    depends on the cell’s style, so it’s parsed once per distinct style, not per cell; relative
    formulas are still shifted from the active cell as before.
  • The step that put the old style back is gone (input_to_cell already starts from the cell’s own
    style).

Tests

crates/engine/tests/range_fill_formats.rs:

  • filled_cells_that_already_hold_a_value_get_the_automatic_format: 5%, $5, 3/4/2026,
    1:30 PM, 1.5E+3 over A1:A2 with A2 holding 1; both cells must match what cell.set gives in
    a fresh cell (text, value, format). Fails on main (5% in A2 shows 0.05).
  • filled_cells_with_their_own_format_keep_it: a 0.000 cell, an empty cell in a 0.00 column
    and a Text row keep their format (and the Text cells get text). Fails on main (the empty
    column-formatted cell takes the active cell’s 0%).
  • filled_formulas_still_shift_and_get_their_date_format: =DATE(2026,3,ROW()) gets m/d/yyyy
    in a cell that held a value, and =C1*2 still shifts to =C2*2. Fails on main (General).
  • a_fill_undoes_in_one_step: guard, passes on main too.

Checks: cargo xtask ci green on main 66ce6be + this commit (fmt, clippy, tests, assets, layers,
wasm, parity, keytips; 1622 tests, 0 failed).

Docs

docs/ui-parity.md: timestamp line and revision history.

Overlap

Question for the maintainers

  • A Text-formatted cell in the selection now gets the input as text (5% stays the text “5%”), as
    typing there does; before, it got the number 0.05 shown in the Text format. Is that the behaviour
    you want for Ctrl+Enter?

Tried in a real window

Windows 11: type 1 in A2, select A1:A2, type 5% and press Ctrl+Enter. Both cells show
5%, as in Excel (on main A2 shows 0.05).

Unverified

  • The Text-cell case and the column-format case weren’t checked against Excel’s Ctrl+Enter.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Range fill now applies automatic number formatting to General-formatted destination cells based on their contents, including cells that already have values.
    • Existing cell, row, column, and Text formatting is preserved during fills. Formulas continue to shift relative to the active cell.
    • A fill operation can be undone in one step.

@coderabbitai

coderabbitai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3a585a15-3e76-4375-90f2-c74476007572
📥 Commits

Reviewing files that changed from the base of the PR and between 66ce6be and 6ac8ad9.

📒 Files selected for processing: 3
  • crates/engine/src/cmd/edit.rs
  • crates/engine/tests/range_fill_formats.rs
  • docs/ui-parity.md

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

📝 Walkthrough

Range fill now parses input using each destination cell’s style. Relative formulas remain shifted from the active cell. Integration tests cover automatic number formats, existing formats, formula shifts, and undo.

Changes: Range fill formatting

Layer / File(s) Summary
Parse and validate range fill by destination style
crates/engine/src/cmd/edit.rs, crates/engine/tests/range_fill_formats.rs, docs/ui-parity.md
range.fill parses input once per distinct destination style. Tests cover automatic number formats, preservation of existing formats, formula shifts, and one-step undo. The UI parity history records the formatting behavior.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: echelon, marcoarnulfo

Merge Risk: ⚪ Minimal · up to 6ac8a

The range-fill change is ready to merge after normal checks; no outstanding behavior issue was established.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 55.56% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 2 files. (1 skipped: 1… 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 describes the main change: Ctrl+Enter fill now applies the number format that typing would apply to each target cell.
Linked Issues check Passed Issue #1919 requires range.fill to apply the automatic format that typing gives to each target, including occupied cells, and to retain target, row, column, and Text formats. range_fill now calls …
Out of Scope Changes check Passed All changed files support issue #1919. The engine change implements per-target parsing. The integration tests verify the required behavior. The docs/ui-parity.md entry documents the same Ctrl+Enter …
Full details: Linked Issues check

Explanation

Issue #1919 requires range.fill to apply the automatic format that typing gives to each target, including occupied cells, and to retain target, row, column, and Text formats. range_fill now calls input_to_cell using each target style and removes the old-style restoration. The new tests cover percentage, currency, date, time, scientific, formatted cells, row and column formats, Text cells, date formulas, relative formula shifts, and one-step undo.

Full details: Out of Scope Changes check

Explanation

All changed files support issue #1919. The engine change implements per-target parsing. The integration tests verify the required behavior. The docs/ui-parity.md entry documents the same Ctrl+Enter behavior and prior defect. No unrelated product behavior is changed.

Full details: Docstring Coverage

Explanation

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

Resolution

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

  • Fix all pre-merge checks with AI
✨ 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.

range.fill parsed the input once at the active cell, then put back the old
style of every target that already held a cell, so 5%, $5, 3/4/2026 or
=DATE(...) lost their automatic format there (0.05, 5, 46085), and empty
targets took the active cell's style. Each target now gets what
input_to_cell gives for it (parsed once per distinct style), as typing does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@h-a-n-a-s-h-i
h-a-n-a-s-h-i merged commit 8e8e2ba into storytold:main Oct 19, 2026
2 checks passed
@echelon

echelon commented Oct 19, 2026

Copy link
Copy Markdown
Member

Merged — thank you @vedran-dobos for the contribution!

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.

fix(edit): Ctrl+Enter drops the automatic number format in cells that already hold a value

3 participants