Skip to content

Fix a null-ref exception in DynamicHelpImpl #2292

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 2 commits into from
Mar 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions PSReadLine/DynamicHelp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ private void DynamicHelpImpl(bool isFullHelp)
string commandName = null;
string parameterName = null;

// Simply return if nothing is rendered yet.
if (_singleton._tokens == null) { return; }

foreach(var token in _singleton._tokens)
{
var extent = token.Extent;
Expand Down
14 changes: 14 additions & 0 deletions test/DynamicHelpTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,13 @@ private static PSObject GetParameterHelpObject(string description)
return paramHelp;
}

[SkippableFact]
public void DynHelp_GetFullHelp_OnEmptyLine()
{
TestSetup(KeyMode.Cmd);
Test("", Keys(_.F1, _.Enter));
}

[SkippableFact]
public void DynHelp_GetFullHelp()
{
Expand All @@ -108,6 +115,13 @@ public void DynHelp_GetFullHelp()
));
}

[SkippableFact]
public void DynHelp_GetParameterHelp_OnEmptyLine()
{
TestSetup(KeyMode.Cmd);
Test("", Keys(_.Alt_h, _.Enter));
}

[SkippableFact]
public void DynHelp_GetParameterHelp_And_Clear()
{
Expand Down