Skip to content

Commit dc38b45

Browse files
authored
Fix a null-ref exception in DynamicHelpImpl (#2292)
1 parent f8fb650 commit dc38b45

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

PSReadLine/DynamicHelp.cs

+3
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,9 @@ private void DynamicHelpImpl(bool isFullHelp)
151151
string commandName = null;
152152
string parameterName = null;
153153

154+
// Simply return if nothing is rendered yet.
155+
if (_singleton._tokens == null) { return; }
156+
154157
foreach(var token in _singleton._tokens)
155158
{
156159
var extent = token.Extent;

test/DynamicHelpTest.cs

+14
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,13 @@ private static PSObject GetParameterHelpObject(string description)
9797
return paramHelp;
9898
}
9999

100+
[SkippableFact]
101+
public void DynHelp_GetFullHelp_OnEmptyLine()
102+
{
103+
TestSetup(KeyMode.Cmd);
104+
Test("", Keys(_.F1, _.Enter));
105+
}
106+
100107
[SkippableFact]
101108
public void DynHelp_GetFullHelp()
102109
{
@@ -108,6 +115,13 @@ public void DynHelp_GetFullHelp()
108115
));
109116
}
110117

118+
[SkippableFact]
119+
public void DynHelp_GetParameterHelp_OnEmptyLine()
120+
{
121+
TestSetup(KeyMode.Cmd);
122+
Test("", Keys(_.Alt_h, _.Enter));
123+
}
124+
111125
[SkippableFact]
112126
public void DynHelp_GetParameterHelp_And_Clear()
113127
{

0 commit comments

Comments
 (0)