Skip to content

Comments

fix(fzf): treat exit code 1 as no matches instead of error#2

Merged
dashed merged 1 commit intodashed:masterfrom
Acren:fix/fzf-exit-code-handling
Aug 8, 2025
Merged

fix(fzf): treat exit code 1 as no matches instead of error#2
dashed merged 1 commit intodashed:masterfrom
Acren:fix/fzf-exit-code-handling

Conversation

@Acren
Copy link
Contributor

@Acren Acren commented Aug 6, 2025

Summary

Fixes fzf error handling to properly treat exit code 1 (no matches found) as an empty result instead of an error.

Changes

  • Add _handle_fzf_error() helper to centralize error processing
  • Return {"matches": []} for no matches vs {"error": "..."} for real errors
  • Apply to both multiline and standard filter modes
  • Update test expectations

- Extract fzf error handling into reusable _handle_fzf_error() helper
- Distinguish between exit code 1 (no matches) and actual errors
- Return consistent dict structure: {"matches": []} vs {"error": "..."}
- Apply to both multiline and standard filter modes
- Update test to expect empty matches instead of error for no results
@dashed
Copy link
Owner

dashed commented Aug 8, 2025

Thank you!

@dashed dashed merged commit 0d24b49 into dashed:master Aug 8, 2025
0 of 9 checks passed
dashed added a commit that referenced this pull request Aug 8, 2025
Add comprehensive test coverage to verify that fzf exit code 2
(actual errors) is properly reported as an error, while exit code 1
(no matches) returns empty results.

Changes:
- Add test_fzf_actual_error_handling() for standard mode
- Add test_fzf_actual_error_handling_multiline() for multiline mode
- Fix bug in multiline mode where fzf return codes weren't checked
- Add returncode attribute to mock objects in existing tests

The tests ensure proper distinction between:
- Exit code 1: No matches found (returns {"matches": []})
- Exit code 2: Actual error (returns {"error": "..."})

This completes the PR #2 follow-up improvements.
dashed added a commit that referenced this pull request Aug 8, 2025
Update documentation to reflect changes from the past 4 days:

CHANGELOG.md:
- Document limit parameter support for search_files and filter_files
- Document fzf exit code handling fixes from PR #2
- Document multiline mode error handling bug fix
- Document test coverage improvements

README.md:
- Add "Recent Updates" section highlighting January 2025 improvements
- Update File Search Server features with limit and error handling
- Add CLI examples demonstrating --limit parameter usage
- Emphasize improved error handling distinguishing "no matches" from errors
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