You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
functions: match TEXTSPLIT/TEXTBEFORE/TEXTAFTER delimiters through an index, within a work limit - #3263
find_matches in crates/functions/src/text.rs (used by TEXTSPLIT, TEXTBEFORE and TEXTAFTER) tried every delimiter at every text position, including repeated delimiters. A formula can pass an array of thousands of delimiters, so the work was text length × delimiter count × delimiter length while the result stayed small.
What changed
Delimiters are sorted and deduplicated, then grouped by their first character (last character when searching from the end). At each position only the group for the character there is compared.
The characters compared in one search are counted; past MAX_MATCH_WORK (100 million) the function returns #VALUE!. find_matches and split_by now return R<…> and their callers propagate it.
Matching rules are unchanged: longest delimiter wins, non-overlapping, case folding as before.
Blast radius
TEXTSPLIT, TEXTBEFORE, TEXTAFTER. Results are the same except that searches over the work limit return #VALUE! instead of running on.
Checks run
cargo test -p gridcraft-functions (new delimiter_matching_stays_bounded: 50,000 copies of one delimiter, 5,000 distinct 1,000-character delimiters over 30,000 characters, longest-match checks from both ends)
… index, within a work limit
The delimiter matcher compared every delimiter, duplicates included, at
every position of the text. Delimiters are now deduplicated and grouped
by the character a match is anchored on, and a search that would
compare more than 100 million characters returns #VALUE!.
Reviewing files that changed from the base of the PR and between 8b65dcd and cead2f8.
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
Trigger review
No actionable comments were generated in the recent review.
Walkthrough
Delimiter matching now indexes deduplicated delimiters by their scan-direction anchor and limits comparison work. TEXTBEFORE, TEXTAFTER, and TEXTSPLIT propagate matching errors.
find_matches indexes nonempty delimiters by their first or last character, selects the longest match, and returns #VALUE! when comparison work exceeds 100,000,000.
Error propagation and coverage crates/functions/src/text.rs
text_before_after, split_by, and textsplit propagate matching errors. Tests cover repeated delimiters, over-budget searches, and longest-match behavior in both directions.
Delimiter matching for TEXTBEFORE, TEXTAFTER and TEXTSPLIT now stops oversized searches with #VALUE! and otherwise behaves as before. The cap is applied per row in TEXTSPLIT rather than across the whole operation, which is a minor gap in the limit and not a correctness problem. No merge-blocking risk remains.
Pre-merge checks: 4 · 1
Failed checks: 1 warning
Check name
Status
Explanation
Resolution
Docstring Coverage
Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta…
Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed checks: 4 passed
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title names the TEXTSPLIT, TEXTBEFORE, and TEXTAFTER delimiter matching change, which is the main change in crates/functions/src/text.rs. It also names the two core ideas: matching through an inde…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title names the TEXTSPLIT, TEXTBEFORE, and TEXTAFTER delimiter matching change, which is the main change in crates/functions/src/text.rs. It also names the two core ideas: matching through an index and a work limit (MAX_MATCH_WORK, returning #VALUE!). It is specific and descriptive, and it is 96 characters long.
Full details: Docstring Coverage
Explanation
Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 4 functions across 1 files.
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
Finishing Touches
Generate docstrings
Commit to this branch
Create a new PR
Generate unit tests (beta)
Commit to this branch
Create a new PR
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.
Reviewing files that changed from the base of the PR and between e6ff2da and 8b65dcd.
Files selected for processing: 1
crates/functions/src/text.rs
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review.
Follow-up commit: the first push's new test passed integer literals where the test helper takes f64, so the test target did not compile (my local run had reused a stale build). Fixed; cargo test -p gridcraft-functions (157 passed) and clippy now pass from a clean target directory.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was wrong
find_matchesincrates/functions/src/text.rs(used by TEXTSPLIT, TEXTBEFORE and TEXTAFTER) tried every delimiter at every text position, including repeated delimiters. A formula can pass an array of thousands of delimiters, so the work was text length × delimiter count × delimiter length while the result stayed small.What changed
MAX_MATCH_WORK(100 million) the function returns#VALUE!.find_matchesandsplit_bynow returnR<…>and their callers propagate it.Blast radius
TEXTSPLIT, TEXTBEFORE, TEXTAFTER. Results are the same except that searches over the work limit return
#VALUE!instead of running on.Checks run
cargo test -p gridcraft-functions(newdelimiter_matching_stays_bounded: 50,000 copies of one delimiter, 5,000 distinct 1,000-character delimiters over 30,000 characters, longest-match checks from both ends)cargo clippy -p gridcraft-functions --all-targets -- -D warningscargo fmt --checkChecks not run
Summary by CodeRabbit
TEXTBEFORE,TEXTAFTER, andTEXTSPLIThandle repeated delimiters consistently while preserving longest-match behavior and scan direction.#VALUE!, and the error is propagated consistently by these functions.