marlonrichert / zsh-autocomplete

🤖 Real-time type-ahead completion for Zsh. Asynchronous find-as-you-type autocompletion.
MIT License
5.38k stars 148 forks source link

"Do you wish to see all X Possibilities?" Bug #635

Closed Thy-GoD closed 1 year ago

Thy-GoD commented 1 year ago

Originally posted as a question but was told to make a bug report instead.

This screenshot sums up the problem:

image

This prompt will sometimes occur mid-typing and basically force me to backspace and re-type the whole thing.

It will sometimes occur for longer commands as well, though I can't remember a case off memory.

Main way to reproduce is to type in curl - and it should show up.

Environment

% typeset -p1 VENDOR OSTYPE ZSH_PATCHLEVEL _autocomplete__funcfiletrace
typeset VENDOR=debian
typeset OSTYPE=linux-gnu
typeset ZSH_PATCHLEVEL=debian/5.9-4+b4
typeset -a _autocomplete__funcfiletrace=(
  /root/.ZSH_FILES/Git/marlonrichert/zsh-autocomplete/zsh-autocomplete.plugin.zsh:4
  /root/.zshrc:34
  /root/.ZSH_FILES/Git/zsh-snap/functions/.znap.source:37
  /root/.ZSH_FILES/Git/zsh-snap/functions/znap:27
  /root/.zshrc:287
  zsh:0
)
% git -C ~autocomplete log --oneline -n1
6d059a3 (grafted, HEAD -> main, tag: 23.07.13, origin/main, origin/HEAD) Fix bugs in insertion logic

Steps to reproduce

% cd $(mktemp -d)
% git clone --depth 1 -- https://github.com/marlonrichert/zsh-autocomplete.git
% > .zshrc <<EOF
setopt interactivecomments transientrprompt
PS1='%# '
PS2=
RPS2='%^'
source $PWD/zsh-autocomplete/zsh-autocomplete.plugin.zsh
EOF
% env -i HOME=$PWD PATH=$PATH TERM=$TERM ${TERMINFO:+TERMINFO=$TERMINFO} zsh -d
% curl -
zsh: do you wish to see all 168 possibilities (86 lines)?
Contents of ~autocomplete-log/2023-8-22.log (click to expand)
zshexit: write error: Input/output error
zshexit: write error: Input/output error
zshexit: write error: Input/output error
zshexit: write error: Input/output error
zshexit: write error: Input/output error
zshexit: write error: Input/output error
zshexit: write error: Input/output error
zshexit: write error: Input/output error
zshexit: write error: Input/output error
zshexit: write error: Input/output error
zshexit: write error: Input/output error
zshexit: write error: Input/output error
zshexit: write error: Input/output error
zshexit: write error: Input/output error
zshexit: write error: Input/output error
zshexit: write error: Input/output error
zshexit: write error: Input/output error
zshexit: write error: Input/output error
zshexit: write error: Input/output error
zshexit: write error: Input/output error
zshexit: write error: Input/output error
zshexit: write error: Input/output error
zshexit: write error: Input/output error
zshexit: write error: Input/output error
zshexit: write error: Input/output error
zshexit: write error: Input/output error
zshexit: write error: Input/output error
zshexit: write error: Input/output error
zshexit: write error: Input/output error
zshexit: write error: Input/output error
zshexit: write error: Input/output error
zshexit: write error: Input/output error
zshexit: write error: Input/output error

This is a repost of an issue thread where I didn't put the format. I might've missed out something in this template but i tried my best to fill it as much as possible.

marlonrichert commented 1 year ago

Sorry, I'm not able to reproduce that. Can you run the following and share the output?

typeset -p COLUMNS LINES
curl -V
curl --help
Thy-GoD commented 1 year ago

Sorry, I'm not able to reproduce that. Can you run the following and share the output?

typeset -p COLUMNS LINES
curl -V
curl --help

Output of first command:

typeset -i10 COLUMNS=157
typeset -i10 LINES=38

Output of 2nd command:

curl 7.88.1 (x86_64-pc-linux-gnu) libcurl/7.88.1 OpenSSL/3.0.10 zlib/1.2.13 brotli/1.0.9 zstd/1.5.5 libidn2/2.3.4 libpsl/0.21.2 (+libidn2/2.3.3) libssh2/1.11.0 nghttp2/1.55.1 librtmp/2.3 OpenLDAP/2.5.13
Release-Date: 2023-02-20
Protocols: dict file ftp ftps gopher gophers http https imap imaps ldap ldaps mqtt pop3 pop3s rtmp rtsp scp sftp smb smbs smtp smtps telnet tftp
Features: alt-svc AsynchDNS brotli GSS-API HSTS HTTP2 HTTPS-proxy IDN IPv6 Kerberos Largefile libz NTLM NTLM_WB PSL SPNEGO SSL threadsafe TLS-SRP UnixSockets zstd

Output of third command:

Usage: curl [options...] <url>
 -d, --data <data>          HTTP POST data
 -f, --fail                 Fail fast with no output on HTTP errors
 -h, --help <category>      Get help for commands
 -i, --include              Include protocol response headers in the output
 -o, --output <file>        Write to file instead of stdout
 -O, --remote-name          Write output to a file named as the remote file
 -s, --silent               Silent mode
 -T, --upload-file <file>   Transfer local FILE to destination
 -u, --user <user:password> Server user and password
 -A, --user-agent <name>    Send User-Agent <name> to server
 -v, --verbose              Make the operation more talkative
 -V, --version              Show version number and quit

This is not the full help, this menu is stripped into categories.
Use "--help category" to get an overview of all categories.
For all options use the manual or "--help all".
marlonrichert commented 1 year ago

What output do you get when you answer y to the question?

Thy-GoD commented 1 year ago

image image

It sorta just breaks.

l4kr commented 1 year ago

git + space shows it a and if I keep typing it basically misses a character Lot of other commands too

Thy-GoD commented 1 year ago

git + space shows it a and if I keep typing it basically misses a character Lot of other commands too

Yeah alot of other commands also have the same issue, mainly if the available flags are plenty. I don't remember every case, but it will make you miss a character.

marlonrichert commented 1 year ago

@Thy-GoD Weird, I have completely different completions for curl:

% curl -V                                                                                                                                 origin<- 643-unit-tests
option
--data         -d    HTTP POST data                                                                                                                            
--fail         -f    Fail fast with no output on HTTP errors                                                                                                   
--help         -h    Get help for commands                                                                                                                     
--include      -i    Include protocol response headers in the output                                                                                           
--output       -o    Write to file instead of stdout                                                                                                           
--remote-name  -O    Write output to a file named as the remote file                                                                                           
--silent       -s    Silent mode                                                                                                                               
--upload-file  -T    Transfer local FILE to destination                                                                                                        
--user         -u    <user-password> Server user and password                                                                                                  
--user-agent   -A    Send User-Agent <name> to server                                                                                                          
--verbose      -v    Make the operation more talkative                                                                                                         
--version      -V    Show version number and quit                                                                                                              
marlonrichert commented 1 year ago

@l4kr What does typeset -p COLUMNS LINES output for you? Also, can you please share the output that you get when you answer y to the question?

marlonrichert commented 1 year ago

@Thy-GoD Ah, now I see: curl supplies its own completion function nowadays, but on macOS, it is not installed by default. When I use curl's own completion function, instead of the default one for curl in zsh, then I can reproduce this.

Thy-GoD commented 1 year ago

@Thy-GoD Ah, now I see: curl supplies its own completion function nowadays, but on macOS, it is not installed by default. When I use curl's own completion function, instead of the default one for curl in zsh, then I can reproduce this.

Interesting, this issue occurs in other commands as well, I'm guessing this is because there's a conflict between the two completion functions?

l4kr commented 1 year ago
typeset -p COLUMNS LINES
typeset -i10 COLUMNS=183
typeset -i10 LINES=43

This is what I typically use when I open the terminal. I resize the terminal all the time tho...

For the git:

Details

``` -- main porcelain command -- add -- add file contents to index am -- apply patches from a mailbox archive -- create archive of files from named tree bisect -- find, by binary search, change that introduced a bug branch -- list, create, or delete branches bundle -- move objects and refs by archive checkout -- checkout branch or paths to working tree cherry-pick -- apply changes introduced by some existing commits citool -- graphical alternative to git commit clean -- remove untracked files from working tree clone -- clone repository into new directory commit -- record changes to repository describe -- show most recent tag that is reachable from a commit diff -- show changes between commits, commit and working tree, etc. fetch -- download objects and refs from another repository format-patch -- prepare patches for e-mail submission gc -- cleanup unnecessary files and optimize local repository grep -- print lines matching a pattern gui -- run portable graphical interface to git init -- create empty git repository or re-initialize an existing one log -- show commit logs merge -- join two or more development histories together mv -- move or rename file, directory, or symlink notes -- add or inspect object notes pull -- fetch from and merge with another repository or local branch push -- update remote refs along with associated objects range-diff -- compare two commit ranges rebase -- forward-port local commits to the updated upstream head reset -- reset current HEAD to specified state restore -- restore working tree files revert -- revert existing commits rm -- remove files from the working tree and from the index shortlog -- summarize git log output show -- show various types of objects stash -- stash away changes to dirty working directory status -- show working-tree status submodule -- initialize, update, or inspect submodules subtree -- split repository into subtrees and merge them switch -- switch branches tag -- create, list, delete or verify tag object signed with GPG worktree -- manage multiple working dirs attached to the same repository -- ancillary manipulator command -- config -- get and set repository or global options fast-export -- data exporter fast-import -- import information into git directly filter-branch -- rewrite branches mergetool -- run merge conflict resolution tools to resolve merge conflicts pack-refs -- pack heads and tags for efficient repository access prune -- prune all unreachable objects from the object database reflog -- manage reflog information remote -- manage set of tracked repositories repack -- pack unpacked objects in a repository replace -- create, list, delete refs to replace objects -- ancillary interrogator command -- blame -- show what revision and author last modified each line of a file count-objects -- count unpacked objects and display their disk consumption difftool -- show changes using common diff tools fsck -- verify connectivity and validity of objects in database help -- display help information about git instaweb -- instantly browse your working repository in gitweb interpret-trailers -- add or parse structured information in commit messages merge-tree -- show three-way merge without touching index rerere -- reuse recorded resolution of conflicted merges show-branch -- show branches and their commits verify-commit -- check GPG signature of commits verify-tag -- check GPG signature of tags version -- show git version whatchanged -- show commit-logs and differences they introduce -- interaction command -- archimport -- import an Arch repository into git cvsexportcommit -- export a single commit to a CVS checkout cvsimport -- import a CVS "repository" into a git repository cvsserver -- run a CVS server emulator for git imap-send -- send a collection of patches to an IMAP folder quiltimport -- apply a quilt patchset request-pull -- generate summary of pending changes send-email -- send collection of patches as emails svn -- bidirectional operation between a Subversion repository and git -- plumbing manipulator command -- apply -- apply patch to files and/or to index checkout-index -- copy files from index to working directory commit-graph -- write and verify Git commit-graph files commit-tree -- create new commit object hash-object -- compute object ID and optionally create a blob from a file index-pack -- build pack index file for an existing packed archive merge-file -- run a three-way file merge merge-index -- run merge for files needing merging mktag -- create tag object mktree -- build tree-object from git ls-tree formatted text multi-pack-index -- write and verify multi-pack-indexes pack-objects -- create packed archive of objects prune-packed -- remove extra objects that are already in pack files read-tree -- read tree information into directory index symbolic-ref -- read and modify symbolic references unpack-objects -- unpack objects from packed archive update-index -- register file contents in the working directory to the index update-ref -- update object name stored in a reference safely write-tree -- create tree from the current index -- plumbing interrogator command -- cat-file -- provide content or type information for repository objects cherry -- find commits not merged upstream diff-files -- compare files in working tree and index diff-index -- compare content and mode of blobs between index and repository diff-tree -- compare content and mode of blobs found via two tree objects for-each-ref -- output information on each ref get-tar-commit-id -- extract commit ID from an archive created using git archive ls-files -- information about files in index/working directory ls-remote -- show references in a remote repository ls-tree -- list contents of a tree object merge-base -- find as good a common ancestor as possible for a merge name-rev -- find symbolic names for given revisions pack-redundant -- find redundant pack files rev-list -- list commit object in reverse chronological order rev-parse -- pick out and massage parameters for other git commands show-index -- show packed archive index show-ref -- list references in a local repository unpack-file -- create temporary file with blob's contents var -- show git logical variable verify-pack -- validate packed git archive files -- plumbing sync command -- daemon -- run a really simple server for git repositories fetch-pack -- receive missing objects from another repository http-backend -- run a server side implementation of Git over HTTP send-pack -- push objects over git protocol to another repository update-server-info -- update auxiliary information file to help dumb servers -- plumbing sync helper command -- http-fetch -- download from remote git repository via HTTP http-push -- push objects over HTTP/DAV to another repository parse-remote -- routines to help parsing remote repository access parameters receive-pack -- receive what is pushed into repository shell -- restricted login shell for GIT-only SSH access upload-archive -- send archive back to git-archive upload-pack -- send objects packed back to git fetch-pack -- plumbing internal helper command -- check-attr -- display gitattributes information check-ignore -- debug gitignore/exclude files check-mailmap -- show canonical names and email addresses of contacts check-ref-format -- ensure that a reference name is well formed column -- display data in columns fmt-merge-msg -- produce merge commit message mailinfo -- extract patch and authorship from a single email message mailsplit -- split mbox file into a list of files merge-one-file -- standard helper-program to use with git merge-index patch-id -- compute unique ID for a patch stripspace -- filter out empty lines ```

On MacOS it doesn't show any prompt at all until I type in something that can be shown (git p...) which would be the preferred behavior. Even better if zsh-autocomplete could show something like first x matches.

marlonrichert commented 1 year ago

@Thy-GoD No, that's not the reason. The reason is that Zsh's own completion function for _curl simply does not produce as many completions as the one that ships with curl itself.

Thy-GoD commented 1 year ago

Ah got it, I've tested on my end and the fix works, curl - no longer has the prompt.