Skip to content

Commit

Permalink
Merge pull request #23 from kanhaiya38/bugfix
Browse files Browse the repository at this point in the history
Fix bug in __abbr_tips_init.fish
  • Loading branch information
gazorby authored Jun 17, 2022
2 parents 1df4f38 + 26a879a commit 5bca1e0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
4 changes: 2 additions & 2 deletions functions/__abbr_tips_init.fish
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function __abbr_tips_init -d "Initialize abbreviations variables for fish-abbr-t
while test $i -le (count $abb)
set -l current_abb (string split -m1 -- ' ' "$abb[$i]")
set -a __ABBR_TIPS_KEYS "$current_abb[1]"
set -a __ABBR_TIPS_VALUES (string trim -c -- '\'' "$current_abb[2]")
set -a __ABBR_TIPS_VALUES (string trim -c '\'' -- "$current_abb[2]")
set i (math $i + 1)
end

Expand All @@ -18,7 +18,7 @@ function __abbr_tips_init -d "Initialize abbreviations variables for fish-abbr-t
while test $i -le (count $abb)
set -l current_abb (string split -m2 -- ' ' "$abb[$i]")
set -a __ABBR_TIPS_KEYS "a__$current_abb[2]"
set -a __ABBR_TIPS_VALUES (string trim -c -- '\'' "$current_abb[3]")
set -a __ABBR_TIPS_VALUES (string trim -c '\'' -- "$current_abb[3]")
set i (math $i + 1)
end
end
27 changes: 23 additions & 4 deletions test/fish-abbreviation-tips.fish
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,20 @@ function setup
end

function teardown
# Restore variables
set __ABBR_TIPS_KEYS $tmp_keys
set __ABBR_TIPS_VALUES $tmp_values
set ABBR_TIPS_PROMPT "$tmp_tips_prompt"
# Restore variables
set __ABBR_TIPS_KEYS $tmp_keys
set __ABBR_TIPS_VALUES $tmp_values
set ABBR_TIPS_PROMPT "$tmp_tips_prompt"
end

function clear_test_var
# Clear variables to prevent the results
# of each unit test from affecting each other
set -g __ABBR_TIPS_KEYS
set -g __ABBR_TIPS_VALUES
abbr -e __abbr_test
abbr -e __abbr_test_one
abbr -e __abbr_test_two
end

setup
Expand Down Expand Up @@ -172,4 +175,20 @@ setup
echo (__abbr_tips 'grep -q')
) = "__abbr_test_alias => grep -q"

@test "multiple abbreviation tip match" (
clear_test_var
abbr -a __abbr_test_one ps
abbr -a __abbr_test_two "grep -q"
__abbr_tips_init
echo (__abbr_tips 'grep -q')
) = "__abbr_test_two => grep -q"

@test "multiple alias tip match" (
clear_test_var
alias abbr_test_alias_one ps
alias abbr_test_alias_two "grep -q"
__abbr_tips_init
echo (__abbr_tips 'grep -q')
) = "abbr_test_alias_two => grep -q"

teardown

0 comments on commit 5bca1e0

Please sign in to comment.