javavscode icon indicating copy to clipboard operation
javavscode copied to clipboard

Plugin never gives suggested imports

Open bowbahdoe opened this issue 9 months ago • 3 comments

Image

Attached is a screen recording of a relatively basic interaction with the plugin. In it I run in to the following issues:

  1. Despite having picocli on the class path, no classes from it are given as suggested imports.
  2. When typing an import it eagerly autocompletes to java.lang.ProcessHandle.Info with no confirmation that its what i wanted. I just typed info.
  3. For a very noticeable period of time after having the correct import in place there is an erroneous red underline under part of the import (the pic in picocli)

I suspect these issues are related so i'm not sure the right way to divide the issues up

Another example of the autocomplete being wack:

Image

bowbahdoe avatar Feb 15 '25 18:02 bowbahdoe

I have found one case where the index didn't work: the first query to the index for a given file must happen before the indexing is done. The easiest way to achieve that is to have the file open, and the classpath setup, stop VS Code, delete the extension's userdir, and start VS Code again. I've attempted to fix that here: https://github.com/apache/netbeans/pull/8255

For 2. - note there's a code completion popup showing Info in the java.lang.ProcessHandle, and . confirms code completion. Also note the code completion is not going to offer info.picocli, as that's not in the picocli jar, as far as I can tell.

lahodaj avatar Feb 18 '25 11:02 lahodaj

@lahodaj . might be the signal you listen to for confirming code completion, but its not a valid signal since it is what you would have typed ignoring the suggested completions. Thats the reason its so jarring - if you aren't looking for at the completion menu and just write code "as normal" it is jumping in with something random. Which is especially bad given how fuzzy of a match it is.

And yeah - its not info.picocli, realized that but i also don't think it affects the overall shape of the issues.

bowbahdoe avatar Feb 18 '25 20:02 bowbahdoe

@lahodaj . might be the signal you listen to for confirming code completion, but its not a valid signal since it is what you would have typed ignoring the suggested completions. Thats the reason its so jarring - if you aren't looking for at the completion menu and just write code "as normal" it is jumping in with something random. Which is especially bad given how fuzzy of a match it is.

Fully agreed. For the record: https://github.com/apache/netbeans/issues/5130

anthonyvdotbe avatar Feb 22 '25 08:02 anthonyvdotbe

Hey @bowbahdoe, You can try our latest extension version, we’ve introduced a new configuration option jdk.java.completion.commit.chars to customize the code completion accept characters.

If everything works as expected, we can go ahead and close this issue.

Achal1607 avatar Oct 09 '25 11:10 Achal1607

And will the default setting for this new configuration option be something sensible, like the Enter key?

bowbahdoe avatar Oct 09 '25 14:10 bowbahdoe

From what I can tell, yes.

bowbahdoe avatar Oct 09 '25 15:10 bowbahdoe

Default is what VSCode provides. So Enter and Tab is the default key.

Achal1607 avatar Oct 09 '25 16:10 Achal1607