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

deno completions only works for deno cli arguments not for file completions #10166

Closed
sspilleman opened this issue Apr 13, 2021 · 8 comments
Closed
Labels
bug Something isn't working correctly cli related to cli/ dir upstream Changes in upstream are required to solve these issues

Comments

@sspilleman
Copy link

sspilleman commented Apr 13, 2021

Hi,

I'm using oh-my-zsh with "deno completions zsh". brew installed them in "/usr/local/share/zsh/site-functions".
I believe the basic completions work brilliantly to autocomplete deno arguments.

Somehow it seems that the "normal" path auto completion is not working.
Let take this example. My command "so far" is:

deno --unstable run --allow-all --import-map=deps.json exa

If I then press tab, I would expect exa to autocomplete to example.ts if that file is in the current directory..... It doesn't. It seems after I start with deno only deno "native" commandline options are presented and not the filesystem

Any Clues?

Sander

@sspilleman
Copy link
Author

sspilleman commented Apr 16, 2021

Does anyone have any clues or workarounds?

@jsejcksn
Copy link
Contributor

I have determined that the lack of completion is caused by using a named parameter which uses =. So in your example the --import-map=deps.json. I haven't researched further.

@sspilleman
Copy link
Author

sspilleman commented Apr 22, 2021

I have determined that the lack of completion is caused by using a named parameter which uses =. So in your example the --import-map=deps.json. I haven't researched further.

If I remove the "=" so my command-line looks like:

deno run --unstable --allow-all --import-map deps.json exa

It still doesn't work :(. If I then manually complete the filename, it still works, so the "=" isn't needed obviously

@lucacasonato
Copy link
Member

Blocked on an upstream issue in clap: clap-rs/clap#568

@lucacasonato lucacasonato added bug Something isn't working correctly upstream Changes in upstream are required to solve these issues cli related to cli/ dir labels Jun 8, 2021
@sspilleman
Copy link
Author

Blocked on an upstream issue in clap: clap-rs/clap#568

It seems there isn't any reasonable progress there, not sure what it means that they removed the 3.0 milestone tags, maybe pushing it further down the roadmap.....

Can't "we" switch to a different library?

@Liamolucko
Copy link
Contributor

It seems like with clap 3, value_hint could be used instead of programmatic completions.

@mcornella
Copy link

I can confirm that using .value_hint fixes file completion in zsh, at least for deno compile, deno test and deno run, with the following changes:

diff --git a/cli/flags.rs b/cli/flags.rs
index 614a975b1..2968a286c 100644
--- a/cli/flags.rs
+++ b/cli/flags.rs
@@ -6,6 +6,7 @@ use clap::Arg;
 use clap::ArgMatches;
 use clap::ArgSettings;
 use clap::ColorChoice;
+use clap::ValueHint;
 use deno_core::serde::Deserialize;
 use deno_core::serde::Serialize;
 use deno_core::url::Url;
@@ -1355,7 +1356,8 @@ fn test_subcommand<'a>() -> App<'a> {
         .help("List of file names to run")
         .takes_value(true)
         .multiple_values(true)
-        .multiple_occurrences(true),
+        .multiple_occurrences(true)
+        .value_hint(ValueHint::FilePath),
     )
     .arg(
       watch_arg(false)
@@ -1799,6 +1801,7 @@ fn script_arg<'a>() -> Arg<'a> {
     ])
     .help("Script arg")
     .value_name("SCRIPT_ARG")
+    .value_hint(ValueHint::FilePath)
 }
 
 fn lock_arg<'a>() -> Arg<'a> {

Of course deno test completion is still broken due to #13702.

I haven't been able to specify value_hint multiple times, so we can't use FilePath and Url for the same argument.

@sspilleman
Copy link
Author

Seems this is fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly cli related to cli/ dir upstream Changes in upstream are required to solve these issues
Projects
None yet
Development

No branches or pull requests

5 participants