Skip to content

Change Get-Help behavior to return local help when no online help available #721

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

Merged
merged 15 commits into from
Sep 21, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
//

using Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol;
using System;

namespace Microsoft.PowerShell.EditorServices.Protocol.LanguageServer
{
// We don't expect ShowOnlineHelpRequest to come from vscode anymore, but it could come from another editor.
// TODO: Note that it's deprecated if it's called???
[Obsolete("This class is deprecated. Use ShowHelpRequest instead.")]
public class ShowOnlineHelpRequest
{
public static readonly
RequestType<string, object, object, object> Type =
RequestType<string, object, object, object>.Create("powerShell/showOnlineHelp");
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a newline here?

public class ShowHelpRequest
public class ShowHelpRequest
{
public static readonly
RequestType<string, object, object, object> Type =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ await requestContext.SendResult(
}
});
}

protected async Task HandleShowHelpRequest(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: newline between functions

string helpParams,
RequestContext<object> requestContext)
Expand Down Expand Up @@ -263,10 +264,9 @@ protected async Task HandleShowOnlineHelpRequest(
RequestContext<object> requestContext
)
{
const string deprecatedWarning = @"
Write-Warning ""'powerShell/showOnlineHelp' has been deprecated. Use 'powerShell/showHelp' instead.""";
PSCommand commandDeprecated = new PSCommand()
.AddScript(deprecatedWarning);
.AddCommand("Microsoft.PowerShell.Utility\\Write-Verbose")
.AddParameter("Message", ";powerShell/showOnlineHelp' has been deprecated. Use 'powerShell/showHelp' instead.");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo here I think (from ; to ')

await editorSession.PowerShellContext.ExecuteCommand<PSObject>(commandDeprecated, sendOutputToHost: true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of (or in addition to) a PSIC warning, we could log a warning to the log file. I could go either way on this.

Copy link
Contributor

@rjmholt rjmholt Sep 18, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 on log file Actually, users won't read the log file, and it won't be relevant when looking back through the logs. We should warn the user somehow.

The ideal would be to launch a popup. But that would be a lot for this PR. Perhaps instead we can leave it as a PSIC message and open an issue to make a popup?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a newline above this await

await this.HandleShowHelpRequest(helpParams, requestContext);
}
Expand Down