File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -509,12 +509,14 @@ function __FUNC__
509509 # --expect gives two lines: key (index 1) and selection (index 2)
510510 # Fish collapses empty lines in command substitution, so when Enter
511511 # is pressed the empty key line disappears and count drops to 1.
512+ set -l _gtr_key
513+ set -l _gtr_line
512514 if test (count $_gtr_selection) -eq 1
513- set -l _gtr_key ""
514- set -l _gtr_line "$_gtr_selection[1]"
515+ set _gtr_key ""
516+ set _gtr_line "$_gtr_selection[1]"
515517 else
516- set -l _gtr_key "$_gtr_selection[1]"
517- set -l _gtr_line "$_gtr_selection[2]"
518+ set _gtr_key "$_gtr_selection[1]"
519+ set _gtr_line "$_gtr_selection[2]"
518520 end
519521 if test "$_gtr_key" = "ctrl-n"
520522 read -P "Branch name: " _gtr_branch
Original file line number Diff line number Diff line change @@ -476,6 +476,17 @@ require_runtime_shell() {
476476 [[ "$output" == *' cd $dir ' * ]]
477477}
478478
479+ @test "fish fzf enter keeps selection variables in function scope" {
480+ run cmd_init fish
481+ [ "$status" -eq 0 ]
482+ [[ "$output" == *' set -l _gtr_key' * ]]
483+ [[ "$output" == *' set -l _gtr_line' * ]]
484+ [[ "$output" == *' set _gtr_key " " ' * ]]
485+ [[ "$output" == *' set _gtr_line " $_gtr_selection [1]" ' * ]]
486+ [[ "$output" != *' set -l _gtr_key " " ' * ]]
487+ [[ "$output" != *' set -l _gtr_line " $_gtr_selection [1]" ' * ]]
488+ }
489+
479490# ── fzf: ctrl-e (editor) — via --expect ──────────────────────────────────────
480491
481492@test "bash fzf ctrl-e handled via --expect for full terminal access" {
You can’t perform that action at this time.
0 commit comments