gazorby / fish-abbreviation-tips

💡 Help you remembering your abbreviations
MIT License
299 stars 7 forks source link

Tips are shown even though abbreviation is used #4

Closed alexanderjeurissen closed 2 years ago

alexanderjeurissen commented 4 years ago

Describe the bug

suggestions/tips are shown to use a certain abbreviation even though the abbrevations was used.

To Reproduce

Using the following abbreviations derived from Prezto git aliases for zsh:

abbr -a -U -- g git
abbr -a -U -- gCa git\ add\ \(git\ status\ \\\|\ sed\ -n\ \\\"s\\/\\\^.\\\*both\ \[a-z\]\\\*ed:\ \\\*\\/\\/p\\\"\)
abbr -a -U -- gCl 'git status | sed -n "s/^.*both [a-z]*ed: *//p"'
abbr -a -U -- gCo 'git checkout --ours --'
abbr -a -U -- gCt 'git checkout --theirs --'
abbr -a -U -- gR 'git remote'
abbr -a -U -- gRa 'git remote add'
abbr -a -U -- gRb git-hub-browse
abbr -a -U -- gRl 'git remote --verbose'
abbr -a -U -- gRm 'git remote rename'
abbr -a -U -- gRp 'git remote prune'
abbr -a -U -- gRs 'git remote show'
abbr -a -U -- gRu 'git remote update'
abbr -a -U -- gRx 'git remote rm'
abbr -a -U -- gS 'git submodule'
abbr -a -U -- gSI 'git submodule update --init --recursive'
abbr -a -U -- gSa 'git submodule add'
abbr -a -U -- gSf 'git submodule foreach'
abbr -a -U -- gSi 'git submodule init'
abbr -a -U -- gSl 'git submodule status'
abbr -a -U -- gSm git-submodule-move
abbr -a -U -- gSs 'git submodule sync'
abbr -a -U -- gSu 'git submodule foreach git pull origin master'
abbr -a -U -- gSx git-submodule-remove
abbr -a -U -- gaa 'git add -A'
abbr -a -U -- gb 'git branch'
abbr -a -U -- gbL 'git branch -av'
abbr -a -U -- gbM 'git branch -M'
abbr -a -U -- gbS 'git show-branch -a'
abbr -a -U -- gbX 'git branch -D'
abbr -a -U -- gbc 'git checkout -b'
abbr -a -U -- gbl 'git branch -v'
abbr -a -U -- gbm 'git branch -m'
abbr -a -U -- gbs 'git show-branch'
abbr -a -U -- gbx 'git branch -d'
abbr -a -U -- gc 'git commit --verbose'
abbr -a -U -- gcF 'git commit --verbose --amend'
abbr -a -U -- gcO 'git checkout --patch'
abbr -a -U -- gcP 'git cherry-pick --no-commit'
abbr -a -U -- gcR 'git reset HEAD^'
abbr -a -U -- gca 'git commit --verbose --all'
abbr -a -U -- gcf 'git commit --amend --reuse-message HEAD'
abbr -a -U -- gcl git-commit-lost
abbr -a -U -- gcm 'git commit --message'
abbr -a -U -- gco 'git checkout'
abbr -a -U -- gcp 'git cherry-pick --ff'
abbr -a -U -- gcr 'git revert'
abbr -a -U -- gcs 'git show'
abbr -a -U -- gd 'git ls-files'
abbr -a -U -- gdc 'git ls-files --cached'
abbr -a -U -- gdi 'git status --porcelain --short --ignored | sed -n "s/^!! //p"'
abbr -a -U -- gdk 'git ls-files --killed'
abbr -a -U -- gdm 'git ls-files --modified'
abbr -a -U -- gdu 'git ls-files --other --exclude-standard'
abbr -a -U -- gdx 'git ls-files --deleted'
abbr -a -U -- gf 'git fetch'
abbr -a -U -- gfc 'git clone'
abbr -a -U -- gfm 'git pull'
abbr -a -U -- gfr 'git pull --rebase'
abbr -a -U -- gg 'git grep'
abbr -a -U -- ggL 'git grep --files-without-matches'
abbr -a -U -- ggi 'git grep --ignore-case'
abbr -a -U -- ggl 'git grep --files-with-matches'
abbr -a -U -- ggv 'git grep --invert-match'
abbr -a -U -- ggw 'git grep --word-regexp'
abbr -a -U -- giA 'git add --patch'
abbr -a -U -- giD 'git diff --no-ext-diff --cached --word-diff'
abbr -a -U -- giR 'git reset --patch'
abbr -a -U -- giX 'git rm -rf --cached'
abbr -a -U -- gia 'git add'
abbr -a -U -- gid 'git diff --no-ext-diff --cached'
abbr -a -U -- gir 'git reset'
abbr -a -U -- giu 'git add --update'
abbr -a -U -- gix 'git rm -r --cached'
abbr -a -U -- gl 'git log --topo-order --pretty=format:"%C(bold)Commit:%C(reset) %C(green)%H%C(red)%d%n%C(bold)Author:%C(reset) %C(cyan)%an <%ae>%n%C(bold)Date:%C(reset) %C(blue)%ai (%ar)%C(reset)%n%+B"'
abbr -a -U -- glb 'git log --topo-order --pretty=format:"%C(green)%h%C(reset) %s%n%C(blue)(%ar by %an)%C(red)%d%C(reset)%n"'
abbr -a -U -- glc 'git shortlog --summary --numbered'
abbr -a -U -- gld 'git log --topo-order --stat --patch --full-diff --pretty=format:"%C(bold)Commit:%C(reset) %C(green)%H%C(red)%d%n%C(bold)Author:%C(reset) %C(cyan)%an <%ae>%n%C(bold)Date:%C(reset) %C(blue)%ai (%ar)%C(reset)%n%+B"'
abbr -a -U -- glg 'git log --topo-order --all --graph --pretty=format:"%C(green)%h%C(reset) %s%C(red)%d%C(reset)%n"'
abbr -a -U -- glo 'git log --topo-order --pretty=format:"%C(green)%h%C(reset) %s%C(red)%d%C(reset)%n"'
abbr -a -U -- gls 'git log --topo-order --stat --pretty=format:"%C(bold)Commit:%C(reset) %C(green)%H%C(red)%d%n%C(bold)Author:%C(reset) %C(cyan)%an <%ae>%n%C(bold)Date:%C(reset) %C(blue)%ai (%ar)%C(reset)%n%+B"'
abbr -a -U -- gm 'git merge'
abbr -a -U -- gmC 'git merge --no-commit'
abbr -a -U -- gmF 'git merge --no-ff'
abbr -a -U -- gma 'git merge --abort'
abbr -a -U -- gmc 'git merge --continue'
abbr -a -U -- gmt 'git mergetool'
abbr -a -U -- gp 'git push'
abbr -a -U -- gpA 'git push --all && git push --tags'
abbr -a -U -- gpa 'git push --all'
abbr -a -U -- gpf 'git push --force'
abbr -a -U -- gpt 'git push --tags'
abbr -a -U -- gr 'git rebase'
abbr -a -U -- gra 'git rebase --abort'
abbr -a -U -- grc 'git rebase --continue'
abbr -a -U -- gri 'git rebase --interactive'
abbr -a -U -- grs 'git rebase --skip'
abbr -a -U -- gs 'git stash'
abbr -a -U -- gsL git-stash-dropped
abbr -a -U -- gsS 'git stash save --patch --no-keep-index'
abbr -a -U -- gsX git-stash-clear-interactive
abbr -a -U -- gsa 'git stash apply'
abbr -a -U -- gsd 'git stash show --patch --stat'
abbr -a -U -- gsl 'git stash list'
abbr -a -U -- gsp 'git stash pop'
abbr -a -U -- gsr git-stash-recover
abbr -a -U -- gss 'git stash save --include-untracked'
abbr -a -U -- gsw 'git stash save --include-untracked --keep-index'
abbr -a -U -- gsx 'git stash drop'
abbr -a -U -- gwC 'git clean -f'
abbr -a -U -- gwD 'git diff --no-ext-diff --word-diff'
abbr -a -U -- gwR 'git reset --hard'
abbr -a -U -- gwS 'git status --ignore-submodules=all'
abbr -a -U -- gwX 'git rm -rf'
abbr -a -U -- gwc 'git clean -n'
abbr -a -U -- gwd 'git diff --no-ext-diff'
abbr -a -U -- gwr 'git reset --soft'
abbr -a -U -- gws 'git status --ignore-submodules=all --short'
abbr -a -U -- gwx 'git rm -r'

When acting uppon a tip

  1. when executing git status --ignore-submodules=all --short it shows the suggestion to use gws sofar so good.
  2. when executing gws it expands to the above. When pressing enter it still suggests to use gws even though I did use that abbreviation.

When using an abbreviation straight away

  1. when executing glg
  2. tip is shown to use glg instead of the expanded version

Expected behavior When using an abbreviation, don't re-suggest to use the abbreviation.

Screenshots image

System (please complete the following information): fish, version 3.1.2 image

gazorby commented 4 years ago

Sorry for the delay! I'm not able to reproduce, do you still have this issue? Also, does it occurs only with gws and glg abbreviations?

alexanderjeurissen commented 4 years ago

Hi @gazorby thanks for following up.

I still have the issue presently. It not only happens with the git abbreviations but with any abbreviation.

I added a zipped screen recording to showcase the issue.

From the looks of it if you wait for a second or two after expanding the abbreviation the hint is not shown. If you are fast and you hit enter after expanding the abbreviation it will incorrectly suggest you should have used an abbreviation.

abbreviations.mp4.zip

gazorby commented 4 years ago

Hi @alexanderjeurissen

Thanks for the detail, your problem looks pretty weird. Do you have any other fish plugins installed? If so, i suggest you uninstall them and keep only fish-abbreviation-tips to see if there would be any potential overlap.

gazorby commented 4 years ago

fish-abbreviation-tips has bindings to space and newline to detect if an abbreviation was used, if you have another fish plugin overriding some of these bindings, it could be the cause of the bug.

novadev94 commented 3 years ago

I'm having the same problem, it happens with all of my abbreviations, not just git ones. Checked the key bindings also, space & enter are properly bound to __abbr_tips_bind_space and __abbr_tips_bind_newline

petertriho commented 3 years ago

This has been happening to me recently as well. Not sure if it's a coincidence but it seemed to have coincided with when I upgraded to fisher 4

gazorby commented 3 years ago

Any news on this? I'm still unable to reproduce this issue.

I even tried in a clean ubuntu:latest docker container and didn't notice any wrong suggestion.

Can you try cleaning your fisher environment and only reinstalling abbreviation-tips?

Before reinstalling, ensure the following variables are removed:

__abbr_tips_used __abbr_tips_run_once __ABBR_TIPS_VALUES __ABBR_TIPS_KEYS ABBR_TIPS_PROMPT ABBR_TIPS_AUTO_UPDATE ABBR_TIPS_ALIAS_WHITELIST ABBR_TIPS_REGEXES

Also make sure these functions doesn't exist anymore:

__abbr_tips_init __abbr_tips_bind_newline __abbr_tips_bind_space __abbr_tips

If all of the above is gone then you should be in a clean environment.

petertriho commented 3 years ago

I've checked that all the variables/functions were removed. Been a while since I've used this plugin but it appears that it only happens with abbr (aliases seem to work fine) e.g. for abbr g -> git

  1. type g<Space>status<CR>
  2. abbr tip shows

I have a bunch of plugins installed so when I have the chance, I'll test it with just abbr tips

mserajnik commented 3 years ago

I can confirm this is happening for me as well.

I have a single abbreviation defined in config.fish:

# Abbreviations
if status --is-interactive
  # Git
  abbr --add --global gs "git status"
end

I'm using the status --is-interactive conditional as it's described in the docs: https://fishshell.com/docs/current/cmds/abbr.html#internals Though this might not be ideal because I had to run __abbr_tips_init manually for the abbreviation tip to show. Edit: I've just tested adding a new abbreviation interactively via abbr --add gf "git fetch" instead and that also didn't show up without me running __abbr_tips_init manually, not even closing all instances of fish and restarting. So I'm not sure what the "best practice" would be here (I just started giving fish a try after using zsh for years, so I'm not really familiar with it yet).

It doesn't matter if I run git status or gs, the abbreviation tip will be shown in both cases.

Using fish version 3.2.1 on Arch Linux. Other plugins installed are:

gazorby commented 3 years ago

@alexanderjeurissen, @NovaDev94 @petertriho, @mserajnik a fix has been merged to enable bindings when using vi mode, can you update the plugin and check if it's fixed?

petertriho commented 3 years ago

@gazorby Awesome! That fixed it for me