Skip to content

Psremoting with Prefix causes intellisense to go wild #2584

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
mattshortland opened this issue Mar 26, 2020 · 11 comments · Fixed by PowerShell/PowerShellEditorServices#1243
Closed
Labels

Comments

@mattshortland
Copy link

Hi all,

I am using the powershell preview and vscode insiders.

I import a module with a prefix eg.

Import-PSSession $EXOSession -prefix O365 -AllowClobber

when i run any commands i get this issue and the console locks up and cannot be recovered until it has finished searching help

Notice it doubles the Prefix in searching help.

Get-Help 100% Searching Help for New-O365O365ActiveSyncDeviceAccessRule ...
Get-Help 100% Searching Help for New-O365O365ActiveSyncDeviceAccessRule ...
Get-Help 100% Searching Help for New-O365O365ActiveSyncDeviceAccessRule ...
Get-Help 100% Searching Help for New-O365O365Mailbox ...
Get-Help 100% Searching Help for New-O365O365Mailbox ...
Get-Help 10% Searching Help for New-O365O365Mailbox ...

@ghost ghost added the Needs: Triage Maintainer attention needed! label Mar 26, 2020
@mattshortland
Copy link
Author

This happens when i highlight an area in the command with the mouse to copy or paste information

@nakosenk
Copy link

This is likely caused by the same root problem I came across with the RemoteDesktop module that I ran into here.

@TylerLeonhardt
Copy link
Member

@nakosenk did you also import the module with a prefix?

@nakosenk
Copy link

I did not import it with a prefix, but it's one of the few Microsoft modules that specifies a Prefix in its module manifest.

@TylerLeonhardt
Copy link
Member

it's one of the few Microsoft modules that specifies a Prefix in its module manifest.

Very good to know.

@TylerLeonhardt
Copy link
Member

Thanks for the info, @bobthewonderdog ! Can you also attach the logs here so we can get a better idea of what's going on?

@TylerLeonhardt
Copy link
Member

when i run any commands i get this issue and the console locks up and cannot be recovered until it has finished searching help

For each item you are looking at in intellisense, we run Get-Help to give you the extra info you see (Parameter details, help text, etc). That is by design in the PowerShell extension:
image

The odd part here is that for cmdlets that use prefix, Get-Help seems to be slower than normal and the progress text shows a duplicate prefix.

You can verify this in PowerShell:

Import-PSSession $EXOSession -prefix O365 -AllowClobber
Get-Command "New-O365ActiveSyncDeviceAccessRule" | Get-Help

When I run that ^ (well for me I just imported a module with a prefix...) the progress text shows:

Get-Help 100% Searching Help for New-O365O365ActiveSyncDeviceAccessRule ...

with the duplicate prefix... but the operation seems to work as expected...

That makes this (and @nakosenk's issue) a PowerShell bug which has two problems:

  • The prefix is duplicated in the progress text - a purely cosmetic issue
  • Get-Help is slow when dealing with a cmdlet that has a prefix...

Can one of you open an issue on each of these things over in https://github.com/PowerShell/PowerShell

@TylerLeonhardt
Copy link
Member

I think given Get-Help's poor perf, we may need to skip over running Get-Help for cmdlets with a prefix...

@nakosenk
Copy link

I haven't had a chance to try it, but the underlying problem might be with CommandInfo.ToString(). When converting a CommandInfo object to a string, it duplicates the prefix, but accessing the Name property gives the correct correct name.

In CommandHelpers.cs, when it builds the call to Get-Command, it passes the name of the command directly which does not duplicate the prefix. But when building the call to Get-Help, it passes the whole CommandInfo object. Changing the argument to be commandInfo.Name should probably resolve the problem.

@TylerLeonhardt
Copy link
Member

@nakosenk yep great find. I was just about to make that exact change :)

Please do open an issue on PowerShell about CommandInfo.ToString() and how it causes Get-Help to fail.

@TylerLeonhardt
Copy link
Member

PR out (for the extension) ^

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