Skip to content

Find and Replace: search only the selected range (#3224) - #3254

Merged
h-a-n-a-s-h-i merged 1 commit into
storytold:mainfrom
hectorviov:feat/find-in-selection
Nov 3, 2026
Merged

h-a-n-a-s-h-i merged 1 commit into
storytold:mainfrom
hectorviov:feat/find-in-selection

Conversation

@hectorviov

Copy link
Copy Markdown
Contributor

Fixes #3224

What changed

  • Engine. edit.find and edit.replace take a new scope, within: "selection", which searches only the selected cells of the active sheet:

    • Find All lists the matches inside the selection.
    • Find Next moves the active cell through those matches and wraps inside the range. The range stays selected, so the next Find Next keeps the same scope.
    • Replace and Replace All change only cells inside the selection.

    sheet and workbook behave as before.

  • Find and Replace dialog. When more than one cell is selected and Within workbook is off, the dialog searches the selection, as Excel does. With one cell selected it still searches the whole sheet.

Three-way comparison

B1:B3 selected; "pear" in A1, B1, A3 and B3:

GridCraft main GridCraft with this PR Excel
Find All 4 matches (A1, B1, A3, B3) 2 matches (B1, B3) only the selected range
Find Next collapses the selection to the match moves the active cell, keeps B1:B3 selected moves the active cell inside the range
Replace All the whole sheet only B1 and B3 only the selected range
one cell selected whole sheet whole sheet whole sheet

Excel's side comes from Microsoft's Find and Replace documentation. It says to select a range of cells to search only that range and to select any one cell to search the whole sheet, and some versions offer Within ▸ Selection. I didn't drive Excel's dialog for this.

Tests

  • cmd::edit::tests::find_and_replace_within_the_selection covers Find All, three Find Next steps (with the wrap and the selection kept), a miss outside the range, Replace inside the range only, and the sheet scope unchanged.
  • find_dialog_focus::find_all_with_a_range_selected_searches_only_the_range drives the dialog (Ctrl+F, type, Find All) with a range selected and with a single cell selected.
  • Both fail when the change is reverted, and cargo xtask ci passes.

Anything a reviewer should look at first

  • The issue suggested an explicit scope. The engine has one (within: selection) for scripts and agents. The dialog chooses it from the selection, like Excel's desktop dialog, so there's no extra control to set.
  • Find Next only moves the active cell when the scope is the selection. With the sheet and workbook scopes it still selects the found cell, as before.

🤖 Generated with Claude Code

edit.find and edit.replace take within: selection, which searches only
the selected cells; Find Next then moves the active cell through them
and keeps the range selected, as Excel does. The Find and Replace
dialog uses it whenever more than one cell is selected (Excel searches
a selected range; one selected cell still means the whole sheet).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 3, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You'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 1 minute.

Check out review usage here.

View limit details

Limit details: You’ve used all 8 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration
Commits

Reviewing files that changed from the base of the PR and between 178f3eb and 3c72d5f.

Files selected for processing: 6
  • crates/engine/src/cmd/edit.rs
  • crates/engine/src/cmd/edit/find.rs
  • crates/engine/src/cmd/edit/tests.rs
  • crates/ui-egui/src/dialogs/find.rs
  • crates/ui-egui/tests/it/find_dialog_focus.rs
  • docs/ui-parity.md
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.

@h-a-n-a-s-h-i
h-a-n-a-s-h-i merged commit ebf762a into storytold:main Nov 3, 2026
1 check passed
h-a-n-a-s-h-i pushed a commit that referenced this pull request Nov 3, 2026
- #3223: sniff the first 64 KiB for a web page and skip JSON and files over the text-import cap, so
  every CSV/TSV is no longer decoded in full before the size check.
- #3253: SYLK relative offsets use checked arithmetic (no overflow on R[9223372036854775807]); at
  most 1024 column-width records are kept; regression test.
- #3254: a single selected merged cell searches the whole sheet, as one selected cell does.
- #3252: the formula bar's height cap is half the room below the ribbon, not half the window, so
  the worksheet stays visible in a short window (CodeRabbit Major).
- #3239, #3244, #3252, #3268: es/de/cs/zh/ko/ru/pt entries for the new interface strings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@echelon

echelon commented Nov 3, 2026

Copy link
Copy Markdown
Member

Merged — thank you @hectorviov for the contribution!

I added one review fix on main (865a789): a single selected merged cell searches the whole sheet, as one selected cell does in Excel.

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.

Find and Replace: restrict search to the selected range

3 participants