fix(edit_file): always retry fuzzy fallback on first search miss#2154
Open
donglovejava wants to merge 1 commit into
Open
fix(edit_file): always retry fuzzy fallback on first search miss#2154donglovejava wants to merge 1 commit into
donglovejava wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request updates the EditFileTool to automatically attempt fuzzy matching when an exact search match is not found, deprecating the explicit fuzz parameter. A review comment correctly points out that the fuzz variable is now unused and should be removed to prevent compiler warnings.
|
|
||
| let count = contents.matches(search).count(); | ||
| let (updated, count, fuzz_kind) = if count == 0 && fuzz { | ||
| let (updated, count, fuzz_kind) = if count == 0 { |
Contributor
There was a problem hiding this comment.
With the removal of the fuzz check here, the fuzz variable defined on line 543 (let fuzz = optional_bool(&input, "fuzz", false);) is now completely unused. This will trigger an unused_variables compiler warning (or error if warnings are treated as errors in CI).\n\nTo fix this, please remove the unused fuzz variable declaration on line 543.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The optional
fuzzparameter was required to attempt the leading-indentation fuzzy fallback when exact search found zero matches. This forced the model to make two calls on every edit that needed fuzzy matching (first without fuzz -> error -> second with fuzz: true), causing a round-trip delay.Fix: remove the
fuzzgate from the count == 0 branch. The tool now automatically retries with indentation-tolerant fuzzy matching when exact search produces no results. Thefuzzparameter is kept in the schema for backward compatibility but marked deprecated.Changes:
if count == 0 && fuzz->if count == 0(always retry fuzzy fallback)else if count == 0 { error }branchGreptile Summary
This PR removes the
fuzzgate from the zero-match branch inEditFileTool::execute, so the indentation-tolerant and punctuation-normalised fuzzy fallbacks now fire automatically whenever an exact search finds nothing. Thefuzzschema parameter is retained and marked deprecated for backward compatibility.if count == 0 && fuzzis simplified toif count == 0, and the now-redundantelse if count == 0 { error }branch is deleted.fuzzare updated to reflect the new automatic-fallback behaviour.Confidence Score: 4/5
Safe to merge; the behavioural change is intentional and the fallback error paths are preserved. The only code-quality gap is a now-unused variable that will emit a compiler warning.
The core logic change is small and correct — the fuzzy fallback paths were already there and tested, and the removed branch was made entirely redundant by the restructured condition. The
fuzzvariable is still parsed but never read, which will generate a Rustunused variablewarning on every build.crates/tui/src/tools/file.rs — the
fuzzbinding at line 543 should be prefixed with_to suppress the compiler warning.Important Files Changed
fuzzgate so indentation- and punctuation-tolerant fuzzy fallbacks are always tried on an exact-match miss. Thefuzzbinding is now unused, producing a compiler warning. Logic and error paths are otherwise correct.Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[edit_file called] --> B{exact match count} B -- count > 0 --> C[replace all occurrences] B -- "count == 0\n(was: count==0 && fuzz)" --> D[indentation fuzzy match] D -- 1 match --> E[replace_range + fuzz_kind = indentation] D -- 0 matches --> F[punctuation fuzzy match] D -- 2+ matches --> G[Error: ambiguous fuzzy match] F -- 1 match --> H[replace_range + fuzz_kind = punctuation] F -- 0 matches --> I[Error: search string not found] F -- 2+ matches --> J[Error: ambiguous punctuation match] C --> K[write file + unified diff] E --> K H --> K B -. removed branch .-> L[was: Error if count==0 and fuzz=false] style L stroke-dasharray: 5 5,fill:#ffccccComments Outside Diff (1)
crates/tui/src/tools/file.rs, line 543 (link)fuzzvalue is parsed into a binding but never referenced after this change. Rust will emit anunused variable: fuzzwarning for every compilation. Prefix the binding with an underscore to signal intentional discard (while still callingoptional_boolto validate the incoming JSON).Reviews (1): Last reviewed commit: "fix(edit_file): always retry fuzzy fallb..." | Re-trigger Greptile