Closed PrzemyslawKlys closed 4 years ago
@PrzemyslawKlys is that type loaded in the PowerShell Integrated Console?
If you run:
PS > [Microsoft.Exchange.WebServices.Data.ExchangeServiceBase]
Do you get anything?
If you get nothing, can you open any PowerShell process, copy and paste your function that doesn't work into it and try to see if tab completion works?
You are correct.
I know what you're going to say 🥴
The thing is I only noticed it because I very often don't get auto-completion in new version. I was able to reproduce it with this one, but I do get it very frequently in the new version for stuff that's local to me. Maybe not all types are loaded correctly the way you're handling it?
And I do hope there could be workaround for this, so that very least unknown types would be handled as Object.
We call out to PowerShell for completions so that will have to be fixed there... Sadly there's nothing we can do.
The workaround, however, is import a module that exposes that type. Then it should work for you. Looks like the Exchange module might expose it maybe considering its an Exchange type?
I'm gonna leave this open for now to remind us to open an issue on PowerShell to handle this better. I'm on vacation for a while but whenever the next triage is we'll make sure to get that issue opened. (unless of course you would like to open it 😊)
Don’t think I can fix it for Exchange. Exchange requires Import-PSSession from Exchange instance. There is no module that can those types as far as I know. Oh well.
I suppose you could always leave that parameter untyped or do an Add-Type with a dummy type of the same name in the Integrated Console so PowerShell won't complain.
We’re talking about 50+ types :-) I just reproduced it wirh one.
@TylerLeonhardt I can open a ticket for PowerShell. However, I am getting this issue in other cases that I can't easily reproduce.
For example just this moment -Color DarkSlateGrey worked, I removed it ... and suddenly I had no autocomplete for Color or anything else for that matter. After multiple retries, it came back.
Color is done on string Register-AutoCompleter. I also wonder if the way I design my modules is not problematic? I use [ScriptBlock] a lot.
I was thinking that the issue may be related to this one: https://github.com/PowerShell/PowerShell/issues/9880 where ScriptBlock is used. I don't use Dynamic Parameters anymore but I do use ScriptBlock a lot and maybe it affects auto-complete when there's ScriptBlock under some weird circumstances.
Yeah there was some work done in PS7 for better support for dynamic parameters and scriptblocks in parameters...
Can you give this a try in PS7 to see if you have the same problem?
@TylerLeonhardt Do you mean original Autocomplete problem? If yes, then yes all versions are affected. If you mean the 2nd one, I haven't tested since the original issue was filed, but doubt anything changed, as it wasn't very long time ago.
@PrzemyslawKlys we are going to resolve this as external as the fix for the original issue will need to come from PowerShell-thanks for opening the issue there https://github.com/PowerShell/PowerShell/issues/11422
@PrzemyslawKlys do you think you can open another issue here capturing the issue about [ScriptBlock] ?
I believe I already did?
Unless you mean something else?
Issue Description
I am experiencing a problem with... autocomplete not working some of the time. I was able to pinpoint it to types that are not available for VSCode and it breaks autocomplete totally. In my case ExchangeServiceBase is not there because I am not connected to EWS. But I believe it's also visible in other cases when types are just not loaded from modules.
This works
The moment you add another parameter with type that is unknown... whole autocomplete breaks.
This shows the issue:
VS Code details from original issue
Attached Logs ===== Follow the instructions in the [README](https://github.com/PowerShell/vscode-powershell%23reporting-problems) about capturing and sending logs. Environment Information ===== Visual Studio Code ----- | Name | Version | | --- | --- | | Operating System | Windows_NT x64 10.0.18363 | | VSCode | 1.41.1| | PowerShell Extension Version | 2019.12.0 | PowerShell Information ----- |Name|Value| |---|---| |PSVersion|5.1.18362.145| |PSEdition|Desktop| |PSCompatibleVersions|1.0 2.0 3.0 4.0 5.0 5.1.18362.145| |BuildVersion|10.0.18362.145| |CLRVersion|4.0.30319.42000| |WSManStackVersion|3.0| |PSRemotingProtocolVersion|2.3| |SerializationVersion|1.1.0.1| Visual Studio Code Extensions -----
Visual Studio Code Extensions(Click to Expand)
|Extension|Author|Version| |---|---|---| |auto-rename-tag|formulahendry|0.1.1| |beautify|HookyQR|1.5.0| |bracket-pair-colorizer-2|CoenraadS|0.0.29| |code-settings-sync|Shan|3.4.3| |codesnap|adpyke|1.0.26| |excel-to-markdown-table|csholmq|1.1.0| |gistfs|vsls-contrib|0.0.23| |github-linker|gimenete|0.2.3| |gitlens|eamodio|10.2.0| |html-preview-vscode|george-alisson|0.2.5| |markdown-all-in-one|yzhang|2.6.1| |markdown-preview-enhanced|shd101wyy|0.5.0| |markdown-shortcuts|mdickin|0.12.0| |material-icon-theme|PKief|3.9.2| |pdf|tomoki1207|0.5.1| |powershell-preview|ms-vscode|2019.12.0| |project-manager|alefragnani|10.9.1| |reg|ionutvmi|1.0.1| |theme-monokai-pro-vscode|monokai|1.1.14| |vscode-html-css|ecmel|0.2.3| |vscode-markdownlint|DavidAnson|0.33.0| |vscode-pull-request-github|GitHub|0.13.0| |vscode-wakatime|WakaTime|2.2.1| |vscode-yaml|redhat|0.6.1| |xml|DotJoshJohnson|2.5.0|