Skip to content

Intellisense provides a lot of junk #1352

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

Closed
PrzemyslawKlys opened this issue Jun 9, 2018 · 21 comments
Closed

Intellisense provides a lot of junk #1352

PrzemyslawKlys opened this issue Jun 9, 2018 · 21 comments
Labels

Comments

@PrzemyslawKlys
Copy link
Contributor

PrzemyslawKlys commented Jun 9, 2018

System Details

  • Operating system name and version: Windows 10 Enterprise Insider
  • VS Code version: 1.24.0
Copy / paste the following commands into the PowerShell Integrated Console, and paste the output here:

PS C:\Users\pklys\OneDrive - Evotec\Support\GitHub\PSPulsewayManager\Public> code -v
1.24.0
6a6e02cef0f2122ee1469765b704faf5d0e0d859
x64
PS C:\Users\pklys\OneDrive - Evotec\Support\GitHub\PSPulsewayManager\Public> $pseditor.EditorServicesVersion

Major  Minor  Build  Revision
-----  -----  -----  --------
1      7      0      0


PS C:\Users\pklys\OneDrive - Evotec\Support\GitHub\PSPulsewayManager\Public> code --list-extensions --show-versions
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
PS C:\Users\pklys\OneDrive - Evotec\Support\GitHub\PSPulsewayManager\Public> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.17672.1000
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.17672.1000
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Actually enabled extensions (the list above has all installed). Probably would be better for you to give a command to get only enabled extensions right?

image

Issue Description

Intellisense is providing a lot of junk.

image

Notice how it was able to pick up the full Set-DriveSettings definition and what it proposes for filling in.

Attached Logs

I've attached lots of logs in different bug report. Let me know if you need more.

@rkeithhill
Copy link
Contributor

Is a PowerShell Editor Services session running? Look in the lower right of the window and it should show the version of PowerShell it is using for the session:

image

If the session is not running you will not get any auto-completion other than what VSCode provides - which is just the tokens in your file.

@PrzemyslawKlys
Copy link
Contributor Author

You are right. It may be that I didn't had the 5.1 running. That's because PowerShell crashes for me very often and I often kill the window. I often see PSAnalyzer being stuck for long time (where I've fixed something and it still complains for the next 2 minutes that variable has bad name or that I have half of the screen red because it didn't notice the change.

Below is what you get until you press -
image

But I guess that's expected?

@PrzemyslawKlys
Copy link
Contributor Author

PrzemyslawKlys commented Jun 9, 2018

On other hand...

image

and here is the definition:

image

But it seems it's only proposed if it's out of parameters. If i remove -LogNameSearch and add - it will just suggest LogNameSearch.

@rkeithhill
Copy link
Contributor

rkeithhill commented Jun 9, 2018

OK, so the PowerShell Editor Services session is running. The next couple of things to try to rule out is script analysis and codelens. You can disable them with the following settings:

  "powershell.scriptAnalysis.enable": false,
  "editor.codeLens": false,

@PrzemyslawKlys
Copy link
Contributor Author

Added. Restarted

image

While the definition:
image

Editor is running. But like I said in earlier report it only proposes junk if you are our of 'your own' parameters.

@rkeithhill
Copy link
Contributor

@PrzemyslawKlys In this case, the PS editor services is reporting no more completions back to VSCode e.g.:

    READ MESSAGE:
    
    {
      "jsonrpc": "2.0",
      "id": 764,
      "method": "textDocument/completion",
      "params": {
        "textDocument": {
          "uri": "file:///c%3A/Users/Keith/GitHub/rkeithhill/vscode-powershell/examples/DebugTest.ps1"
        },
        "position": {
          "line": 61,
          "character": 5
        }
      }
    }

    WRITE MESSAGE:
    
    {
      "jsonrpc": "2.0",
      "id": "764",
      "result": []
    }

What you are seeing in the completion list above is provided by VSCode and it represents matching tokens (those starting with -) in your file.

I'm looking around to see if there is a way to indicate to VSCode that there are no more valid completions in this situation. So far, I'm coming up with nothing.

@PrzemyslawKlys
Copy link
Contributor Author

That's what I thought after a couple of your explanation posts above. It would be nice to know Editor Services are done with it's work and now you are using VSCode junk ;) Thanks for looking into this.

@PrzemyslawKlys
Copy link
Contributor Author

PrzemyslawKlys commented Jun 11, 2018

junk-ontype

I type this method... i even run F5 to make sure powershell is initilized before trying intellisense. And it seems VSCode picks the standard token that i used above '-eq' and not the one proposed. I press CTRL+SPACE multiple times.

@PrzemyslawKlys
Copy link
Contributor Author

junk-ontype

Here is another example. As you can see it's not showing any good help for -Bold which is [bool[]] while it shows [UnderlineStyle[]] properly.

The Add-WordText is available here: https://github.com/EvotecIT/PSWriteWord/blob/master/Public/PSWordParagraph.ps1

Maybe it's just the way I use it...

@TylerLeonhardt
Copy link
Member

Hey @PrzemyslawKlys,

Thanks for the gifs, they're really helpful! So I think the gif about Get-Test -Change is a performance bug. I think that if you had waited a bit longer, you would have gotten a response. We're working on addressing perf-related issues - we've gotten a lot of feedback on them.

Your second gif, I think, is actually a limitation of PowerShell. If you load that cmdlet Add-WordText into a regular console, do you get completions for the bool[]?

@PrzemyslawKlys
Copy link
Contributor Author

Hey @tylerl0706 ,

You are right. I get same behaviour in ISE and powershell for bool[]. As for the 1st example it seems variable type needs to defined. If it's not defined you won't get completion in ISE either. When I changed it to bool it works straight away.

So I guess in both cases it's kind of expected although confusing.

Przemek

@TylerLeonhardt
Copy link
Member

Both the ISE and VSCode PowerShell get completions via TabExpansion2 which is built in to PowerShell.

Definitely open an issue on PowerShell voicing this so we can fix it there 😃

If TabExpansion2 doesn't give VSCode any results, VSCode tries to "help" by supplying completions of things you've typed previously or common PowerShell things. You might be able to disable these but I'm not sure off the top of my head - I think that's really on VSCode.

@rjmholt
Copy link
Contributor

rjmholt commented Jun 19, 2018

@PrzemyslawKlys, to import those types properly, you might want to try the using keyword. You might get better intellisense then as well.

@PrzemyslawKlys
Copy link
Contributor Author

@rjmholt I actually followed different pattern where I've use ScriptsToProcess in .psd1 where I've put all Enums in. https://github.com/EvotecIT/PSWriteWord/blob/master/PSWriteWord.psd1 That's what I found in someones other script. In the test I did, it was just a test so haven't really verified it. Assumed it would work. I will read on Using in PowerShell. I know using in C#. Eh there's a lot to learn ;-)

@PrzemyslawKlys
Copy link
Contributor Author

@tylerl0706 but isn't that for PowerShell 6+ only? I'm still using the standard version? Or will you port it to the Windows edition as well if I report it as a bug?

@TylerLeonhardt
Copy link
Member

It won't get ported back to Windows PowerShell but eventually PowerShell 6+ will become the version of PowerShell everyone uses so it would be nice to have an issue to track that we could do better in TabExpansion2 😊

@PrzemyslawKlys
Copy link
Contributor Author

PrzemyslawKlys commented Jun 28, 2018

Another example... notice how I type -Autofit ... it should only provide 4 entries (the top ones). For some reason it provides a bunch. Then i go and change -Design... notice notice how it push me to the last entries showing me junk and I have to scroll up.

pswriteword-tables-example3

It's not related to [] or anything. Just enum loaded from module I wrote.

@PrzemyslawKlys
Copy link
Contributor Author

PrzemyslawKlys commented Jan 29, 2019

Thought I would resurrect this:

image

ValidateSet is simple 1 to 6. Lots of other options that shouldn't show up.

In standard PowerShell:

image

@SeeminglyScience
Copy link
Collaborator

@PrzemyslawKlys those are snippets, VSCode will display them regardless of what this extension says the results should be. You can disable that with this setting:

"editor.snippetSuggestions": "none",

@PrzemyslawKlys
Copy link
Contributor Author

@SeeminglyScience Did I ever told you I love you? If not, here's the first time! Works as advertised.

Now question is, should I close this one? Or do you think that earlier issue requires any work?

@SeeminglyScience
Copy link
Collaborator

SeeminglyScience commented Jan 29, 2019

Now question is, should I close this one? Or do you think that earlier issue requires any work?

Looks like the other issues in the thread are related to the completions provided by the engine. I didn't look close enough to tell if they've already been reported, but any issues for improving the engine's completion would need to be on the PowerShell repo. In other words, yeah I suspect this can safely closed.

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

No branches or pull requests

5 participants