Skip to content

Commit 437e71e

Browse files
fix GetVersionDetails error (#641)
* fix GetVersionDetails error * cleaner conditional
1 parent e28c9eb commit 437e71e

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/PowerShellEditorServices/Session/PowerShellContext.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ await Task.Factory.StartNew<IEnumerable<TResult>>(
535535
if (this.powerShell.HadErrors)
536536
{
537537
var strBld = new StringBuilder(1024);
538-
strBld.AppendFormat("Execution of the following command(s) completed with errors:\r\n\r\n{0}\r\n",
538+
strBld.AppendFormat("Execution of the following command(s) completed with errors:\r\n\r\n{0}\r\n",
539539
GetStringForPSCommand(psCommand));
540540

541541
int i = 1;
@@ -838,15 +838,14 @@ await this.ExecuteCommand<object>(
838838

839839
Collection<PSObject> results = pipeline.Invoke();
840840

841-
if (results.Count == 0)
841+
if (results.Count == 0 || results.FirstOrDefault() == null)
842842
{
843843
return defaultValue;
844844
}
845845

846846
if (typeof(TResult) != typeof(PSObject))
847847
{
848-
return
849-
results
848+
return results
850849
.Select(pso => pso.BaseObject)
851850
.OfType<TResult>()
852851
.FirstOrDefault();

0 commit comments

Comments
 (0)