Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FR: Dynamic completion should suggest options only when input is prefixed with - #5201

Open
raxyte opened this issue Dec 28, 2024 · 5 comments

Comments

@raxyte
Copy link

raxyte commented Dec 28, 2024

Is your feature request related to a problem? Please describe.
Dynamic completions suggest short form and long form options as well as completions for positional arguments. This adds a lot of clutter since they are intertwined with each other (presumably during sorting?), requiring visually filtering out positional suggestions from option names.

Describe the solution you'd like
Completions should only suggest options when the input is prefixed with at least -.

Describe alternatives you've considered
Switching back to static completions which do have this behavior but none of the niceties.

Additional context
Thanks for this fantastic project! Cheers to everyone contributing. ❤️

@samueltardieu
Copy link
Contributor

samueltardieu commented Dec 28, 2024

What shell are you using? With fish, I get only command and file completions unless I type - first, and even then the long and short options are grouped:

$ jj <TAB>
abandon                                                              (Abandon a revision)
absorb                 (Move changes from a revision into the stack of mutable revisions)
backout                      (Apply the reverse of a revision on top of another revision)
bookmark                                            (Manage bookmarks [default alias: b])
branch                                              (Manage bookmarks [default alias: b])
cat                                               (Print contents of files in a revision)
chmod                          (Sets or removes the executable bit for paths in the repo)
commit                            (Update the description and create a new change on top)
config                                                            (Manage config options)
debug                                         (Low-level commands not intended for users)
desc                                    (Update the change description or other metadata)
describe                                (Update the change description or other metadata)
diff                                        (Compare file contents between two revisions)
…and 39 more rows

$ jj log -<TAB>
-h  --help                                     (Print help (see more with '--help'))
-l                                                                                  
-n  --limit                                      (Limit number of revisions to show)
-p  --patch                                                             (Show patch)
-R  --repository                                  (Path to repository to operate on)
-r  --revisions                                            (Which revisions to show)
-s  --summary  (For each path, show only whether it was modified, added, or deleted)
-T  --template                       (Render each revision using the given template)
--at-op  --at-operation                              (Operation to load the repo at)
--color                       (When to colorize output (always, never, debug, auto))
--color-words          (Show a word-level diff with changes indicated only by color)
--config                        (Additional configuration options (can be repeated))
--config-file                     (Additional configuration files (can be repeated))
…and 16 more rows

@raxyte
Copy link
Author

raxyte commented Dec 28, 2024

I am using zsh.

tenzir on  HEAD
❯ source <(COMPLETE=zsh jj)

tenzir on  HEAD
❯ jj <TAB>
abandon                -- Abandon a revision
absorb                 -- Move changes from a revision into the stack of mutable revisions
--at-operation         -- Operation to load the repo at
backout                -- Apply the reverse of a revision on top of another revision
bookmark               -- Manage bookmarks [default alias: b]
--color                -- When to colorize output (always, never, debug, auto)
commit                 -- Update the description and create a new change on top
config                 -- Manage config options
--config-toml          -- Additional configuration options (can be repeated)
--debug                -- Enable debug logging
desc                   -- Update the change description or other metadata
diff                   -- Compare file contents between two revisions
diffedit               -- Touch up the content changes in a revision with a diff editor
duplicate              -- Create new changes with the same content as existing ones
edit                   -- Sets the specified revision as the working-copy revision
evolog                 -- Show how a change has evolved over time
file                   -- File operations
fix                    -- Update files with formatting fixes or other changes
git                    -- Commands for working with Git remotes and the underlying Git repo
--help                 -- Print help (see more with '--help')
help                   -- Print this message or the help of the given subcommand(s)
--ignore-immutable     -- Allow rewriting immutable commits
--ignore-working-copy  -- Don't snapshot the working copy, and don't update it
init                   -- Create a new repo in the given directory
interdiff              -- Compare the changes of two commits
log                    -- Show revision history
new                    -- Create a new, empty change and (by default) edit it in the working copy
next                   -- Move the working-copy commit to the child revision
--no-pager             -- Disable the pager
op                     -- Commands for working with the operation log
parallelize            -- Parallelize revisions by making them siblings
prev                   -- Change the working copy revision relative to the parent revision
--quiet                -- Silence non-primary command output
rebase                 -- Move revisions to different parent(s)
--repository           -- Path to repository to operate on
resolve                -- Resolve a conflicted file with an external merge tool
restore                -- Restore paths from another revision
root                   -- Show the current workspace root directory
show                   -- Show commit description and changes in a revision
simplify-parents       -- Simplify parent edges for the specified revision(s)
sparse                 -- Manage which paths from the working-copy commit are present in the working copy
split                  -- Split a revision in two
squash                 -- Move changes from a revision into another revision
st                     -- Show high-level repo status
tag                    -- Manage tags
undo                   -- Undo an operation (shortcut for `jj op undo`)
util                   -- Infrequently used commands such as for generating shell completions
version                -- Display version information
--version              -- Print version
workspace              -- Commands for working with workspaces
amend    unamend

@raxyte
Copy link
Author

raxyte commented Dec 28, 2024

As you can imagine, this get unwieldy when trying to find a revision from the suggestions etc.

@raxyte
Copy link
Author

raxyte commented Dec 28, 2024

In your second example as well, ideally (IMO) you should not get suggestions for options but only revisions, unless you had typed jj log -r -<TAB> instead of jj log -r <TAB>.

@samueltardieu
Copy link
Contributor

In your second example as well, ideally (IMO) you should not get suggestions for options but only revisions, unless you had typed jj log -r - instead of jj log -r .

I had not typed the r, it appeared as greyed and I copied it by mistake, I had only typed -. I'll fix it right away.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants