Skip to content

fix(init): keep fish fzf selection in scope#172

Merged
helizaga merged 1 commit intomainfrom
fix/fish-fzf-cd-scope
Apr 27, 2026
Merged

fix(init): keep fish fzf selection in scope#172
helizaga merged 1 commit intomainfrom
fix/fish-fzf-cd-scope

Conversation

@helizaga
Copy link
Copy Markdown
Collaborator

@helizaga helizaga commented Apr 27, 2026

Summary

  • Fix Fish shell integration so gtr cd fzf Enter keeps _gtr_key and _gtr_line in function scope.
  • Add BATS regression coverage for the generated Fish wrapper.

Fixes #169.

Testing

  • bats tests/init.bats
  • bats tests/
  • shellcheck lib/commands/init.sh
  • git diff --check

Summary by CodeRabbit

  • Refactor

    • Improved variable declaration logic for better code reliability and consistency.
  • Tests

    • Added test case to verify variable scoping and assignment behavior in the initialization handler.

@helizaga helizaga requested a review from NatoBoram as a code owner April 27, 2026 21:40
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 27, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 87644129-0972-42a0-bc02-f760dc9485f0

📥 Commits

Reviewing files that changed from the base of the PR and between b8ca496 and 39af5e9.

📒 Files selected for processing (2)
  • lib/commands/init.sh
  • tests/init.bats

Walkthrough

Fish shell variable scoping issue fixed in the gtr cd fzf interactive picker. Variables _gtr_key and _gtr_line are now predeclared in function scope before conditional assignment, preventing them from being scoped to if/else block boundaries. A new test validates correct variable scoping behavior.

Changes

Cohort / File(s) Summary
Fish Shell Scoping Fix
lib/commands/init.sh
Moved set -l declarations of _gtr_key and _gtr_line outside the if/else block and converted conditional assignments to plain set to preserve function-scope visibility. Addresses issue where variables declared inside blocks become inaccessible after block end.
Variable Scoping Test
tests/init.bats
Added test case validating that _gtr_key and _gtr_line are declared with function-local scope and correctly assigned based on fzf selection count. Verifies the fix prevents variable scope leakage.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A Fish swam deep in scope's dark sea,
Where variables hid where they shouldn't be,
But now with set -l placed just right,
Those local vars stay in sight!
The rabbit hops, the cd works true,
Fish shell scoping—problem through! 🌳

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ 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 accurately summarizes the main change: fixing Fish shell variable scoping for fzf selection in the init function to keep variables in function scope rather than block scope.
Linked Issues check ✅ Passed The pull request directly addresses issue #169 by implementing the suggested fix: declaring _gtr_key and _gtr_line in function scope before the if/else block and assigning without -l inside branches. A regression test is also added as requested.
Out of Scope Changes check ✅ Passed All changes are within scope: the init.sh fix directly addresses the Fish scoping issue from #169, and the test addition provides regression coverage as suggested in the issue.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/fish-fzf-cd-scope

Comment @coderabbitai help to get the list of available commands and usage tips.

@helizaga helizaga merged commit d182c32 into main Apr 27, 2026
4 checks passed
@helizaga helizaga deleted the fix/fish-fzf-cd-scope branch April 27, 2026 21:45
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.

gtr cd fzf picker on fish: set -l inside if/else scopes variables to the block, so cd never executes

1 participant