Skip to content

Commit

Permalink
Fix a null-ref exception in DynamicHelpImpl (#2292)
Browse files Browse the repository at this point in the history
  • Loading branch information
daxian-dbw authored Mar 11, 2021
1 parent f8fb650 commit dc38b45
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
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

0 comments on commit dc38b45

Please sign in to comment.