Add autocomplete for nested examples#15574
Add autocomplete for nested examples#15574MrMinimal wants to merge 1 commit intorust-lang:masterfrom MrMinimal:master
Conversation
| [ -z "$manifest" ] && return 0 | ||
|
|
||
| local files=("${manifest%/*}"/examples/*.rs) | ||
| local files=("${manifest%/*}"/examples/**/*.rs) |
There was a problem hiding this comment.
Should we do something similar for zsh?
Lines 472 to 477 in c2c636a
| [ -z "$manifest" ] && return 0 | ||
|
|
||
| local files=("${manifest%/*}"/examples/*.rs) | ||
| local files=("${manifest%/*}"/examples/**/*.rs) |
There was a problem hiding this comment.
This could pick up both examples and submodules. Unsure whether that is worth it or not
There was a problem hiding this comment.
I would be a little worried that the false-positive rate would be too high. In bevy for example, this would auto-complete a ton of names that aren't examples.
I think the only real solution here is to parse Cargo.toml, and I think native-completions is the only way to realistically do that. This bashcomp could do some json parsing of cargo metadata, but I wouldn't want to go there.
|
Are you aware of our experimental completion system (docs)? It uses |
|
@epage I wasn't aware of the experimental system, just wanted to contribute back a quick fix I had. |
What does this PR try to resolve?
Not all examples show up in auto-completion.
If the
examplesdirectory has nested examples, only the top level ones will be shown withcargo build --example<TAB>.cargo build --example<TAB>.Bevy examples only show
hello_worldinstead of all available examples.Old:

New:

How should we test and review this PR?
The completion logic for me is in
~/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/etc/bash_completion.d/cargo.So to test, this has to be edited as it doesn't get updated when you simply build cargo (I think rustup installs it).
Then go into a Rust project with nested examples (e. g. Bevy) and type
cargo build --exampleand press<TAB>.