yadm icon indicating copy to clipboard operation
yadm copied to clipboard

yadm add auto-complete slow on zsh 5.8 with compinit loaded and enabled

Open D-Vaillant opened this issue 3 years ago • 11 comments

Describe the bug

In general, when I try to tab-autocomplete filenames when using yadm, it lags exceptionally bad to the point where I sometimes have to CTRL-C to do something different. I generally end up killing __git_files, __multi_parts, of __git_command_succesful.

This does not occur with other command tab-completes that I've observed.

To reproduce

Can this be reproduced with the yadm/testbed docker image: Unsure

Steps to reproduce the behavior:

  1. Have the following in your .zshrc: autoload -U compinit; compinit.
  2. Enter yadm add ~/.z, hit Tab. (Or try other completes.)
  3. This will eventually resolve, but after a while.

Expected behavior

Tab auto-completes take a normal amount of time, on the order of milliseconds and not seconds.

Environment

  • Operating system: 5.4.124-1-MANJARO
  • Version yadm: 3.0.2
  • Version Git: 2.32.0
  • Version zsh: 5.8

D-Vaillant avatar Jul 10 '21 19:07 D-Vaillant

@D-Vaillant - What's the output of yadm gitconfig --get status.showUntrackedFiles for you?

TheLocehiliosan avatar Nov 29 '21 19:11 TheLocehiliosan

~ >>> yadm gitconfig --get status.showUntrackedFiles
no

Environment

Operating system: 5.10.82-1-MANJARO
Version yadm: 3.0.2
Version Git: 2.34.1
Version zsh: 5.8

D-Vaillant avatar Dec 06 '21 14:12 D-Vaillant

Oh, important additional information: it only happens when I'm in my home directory. If I'm in a smaller sub-directory it works as expected.

I've reproduced it using just pure git so this is probably a zsh compinit issue and not a yadm issue.

D-Vaillant avatar Dec 06 '21 14:12 D-Vaillant

I have the same issue, but I am using Fish. After I press "tab", it never completes. My fish process pegs the CPU at 100%. I have to CTRL-C to regain access to my shell.

cmer avatar Dec 19 '21 22:12 cmer

I'm seeing this too in fish, and I think it is caused by an interaction with the built-in git completions.

The line complete -c yadm -w "git --git-dir=$GIT_DIR" at the bottom of yadm.fish hooks into the standard git completions when you are using the git commands (like add). The git completion shipped with fish helpfully scans files to tell you if they are untracked or not, but in this case scans your whole home directory, so it takes ages.

I have tried experimenting with something like the line below to try and work around it, but I can't seem to get it working. Anyone have any ideas?

complete -c yadm -n "not __fish_yadm_using_command add" -w "git --git-dir=$GIT_DIR"

rotech avatar Jan 07 '22 01:01 rotech

This issue has been labeled as stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Mar 08 '22 01:03 github-actions[bot]

same issue here, I found that overriding __git_files with this function solves the problem for me:

__git_files () { 
    _wanted files expl 'local files' _files     
}

thats for zsh, idk about fish but its probably a similar solution, the original function is shipped by zsh source: https://stackoverflow.com/a/9810485

rvalieris avatar Mar 12 '22 20:03 rvalieris

Another possibility would be for yadm to ship with a sensible ~/.gitignore out of the box. Here's mine, outside of the already tracked excludes anyone should be able to use and edit this without issue. Feel free to PR or check the source in case I update it https://github.com/xenoterracide/dotfiles/blob/master/.gitignore

yadm status -u will tell you all of the massive garbage that yadm add <tab> is trying to autocomplete

## already tracked
.zshrc
.zshenv
.gitconfig

## compiled dynamic langauages
*.pyc
*.zwc

*.log

*.idea
*.iml
*.code-workspace

# You may want to customise this file depending on your Operating System
# and the editor that you use.
#
# We recommend that you use a Global Gitignore for files that are not related
# to the project. (https://help.github.com/articles/ignoring-files/#create-a-global-gitignore)

# OS
#
# Ref: https://github.com/github/gitignore/blob/master/Global/macOS.gitignore
# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

# Ref: https://github.com/github/gitignore/blob/master/Global/Windows.gitignore
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db

# Dump file
*.stackdump

# Folder config file
[Dd]esktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp

# Windows shortcuts
*.lnk

# Ref: https://github.com/github/gitignore/blob/master/Global/Linux.gitignore
*~

# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*

# KDE directory preferences
.directory

# Linux trash folder which might appear on any partition or disk
.Trash-*

# .nfs files are created when an open file is removed but is still being accessed
.nfs*

# Archives
# https://github.com/github/gitignore/blob/master/Global/Archives.gitignore
# It's better to unpack these files and commit the raw source because
# git has its own built in compression methods.
*.7z
*.jar
*.rar
*.zip
*.gz
*.gzip
*.tgz
*.bzip
*.bzip2
*.bz2
*.xz
*.lzma
*.cab
*.xar
*.zst

# Packing-only formats
*.iso
*.tar

# Package management formats
*.dmg
*.xpi
*.gem
*.egg
*.deb
*.rpm
*.msi
*.msm
*.msp
*.txz

# Editors
#
# Ref: https://github.com/github/gitignore/blob/master/Global
# Ref: https://github.com/github/gitignore/blob/master/Global/JetBrains.gitignore
# Ref: https://github.com/github/gitignore/blob/master/Global/VisualStudioCode.gitignore
.idea

*.swp

# Homedir
Videos/
Pictures/
Downloads/
IdeaProjects/
Templates/
Dropbox/
Desktop/
Documents/
.cache/
caches/
.zoom/
.zi/
.vscode-oss/
.vim/
.thunderbird/
.sylpheed-2.0/
.steam*
.ssh/
.pki/
.pkg-cache/
.spamassassin/
.phoronix-test-suite/
.parallel/
.nvm/
.npm/
.node/
.mozilla/
.minikube/
.m2/repository/
*history*
.local/
.kde4/
.jdks/
.java/
.hyper_plugins/
.gradle/
.gnupg/
.electron-gyp/
.dropbox*/
.claws-mail/
.cargo/
.asdf/
.adobe-reader*/

## .config abusers
.config/opera/
.config/evolution/
.config/discord/
.config/hexchat/
.config/zconvey/
.config/pulse/
.config/gtk-*/
.config/ranger/
.config/ibus/
.config/chromium/
.config/akonadi/
.config/Slack/
.config/Signal/
.config/Microsoft/
.config/JetBrains/
.config/Hyper/
.config/FontBase/
.config/Code - OSS/
.config/Bitwarden/

xenoterracide avatar Mar 16 '22 10:03 xenoterracide

Could someone look into this? It's not really a stopper but kind of makes me feel dirty :D

gabrielps avatar Apr 07 '22 06:04 gabrielps

I'm also running into this problem using fish. @TheLocehiliosan Is there a recommended way how to handle this problem? Thanks!

januz avatar May 09 '23 14:05 januz

Great tip, @xenoterracide. I solved my issue with what you said. Here's my .gitignore, for the record.

# MacOS
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon

# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

# Ref: https://github.com/github/gitignore/blob/master/Global/Windows.gitignore
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db

# Dump file
*.stackdump

# Folder config file
[Dd]esktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp

# Windows shortcuts
*.lnk

# Ref: https://github.com/github/gitignore/blob/master/Global/Linux.gitignore
*~

# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*

# KDE directory preferences
.directory

# Linux trash folder which might appear on any partition or disk
.Trash-*

# .nfs files are created when an open file is removed but is still being accessed
.nfs*

# Archives
# https://github.com/github/gitignore/blob/master/Global/Archives.gitignore
# It's better to unpack these files and commit the raw source because
# git has its own built in compression methods.
*.7z
*.jar
*.rar
*.zip
*.gz
*.gzip
*.tgz
*.bzip
*.bzip2
*.bz2
*.xz
*.lzma
*.cab
*.xar
*.zst

# Packing-only formats
*.iso
*.tar

# Package management formats
*.dmg
*.xpi
*.gem
*.egg
*.deb
*.rpm
*.msi
*.msm
*.msp
*.txz

###Tags###

# Ignore tags created by etags, ctags, gtags (GNU global) and cscope
TAGS
!TAGS/
tags
!tags/
gtags.files
GTAGS
GRTAGS
GPATH
cscope.files
cscope.out
cscope.in.out
cscope.po.out

# Other stuff
lnav
*.log
*.idea
*.iml
*.code-workspace
*.swp

## compiled dynamic langauages
*.pyc
*.zwc

## YADM ignores to speed up autocompletion
.asdf/installs
.asdf/shims
.asdf/plugins
.asdf/tmp
.bundle/cache
.cache
.cargo
.colima/_wrapper
.npm
.platformio
.vscode/extensions
Library
Downloads
Pictures
golang

cmer avatar May 09 '23 14:05 cmer