Skip to content

Commit

Permalink
Merge pull request #22 from VelvetToroyashi/fix/enumerators
Browse files Browse the repository at this point in the history
Fix enumerator bug
  • Loading branch information
Nihlus committed Nov 14, 2023
2 parents aae457a + b942471 commit 95d8840
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions Remora.Commands/Trees/Nodes/CommandNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -201,19 +201,13 @@ public bool TryBind
var boundParameters = new List<BoundParameterShape>();
while (parametersToCheck.Count > 0)
{
// The return value of MoveNext is ignored, because empty collections are allowed
_ = enumerator.MoveNext();

// Because the current enumerator might be invalid or ended, we'll fix up the key-value pair here
var current = enumerator.MoveNext()
? enumerator.Current
: KeyValuePair.Create(string.Empty, (IReadOnlyList<string>)Array.Empty<string>());
var matchedParameters = new List<IParameterShape>();
foreach (var parameterToCheck in parametersToCheck)
{
// Because the current enumerator might be invalid or ended, we'll fix up the key-value pair here
var current = enumerator.Current;
if (current.Equals(default(KeyValuePair<string, IReadOnlyList<string>>)))
{
current = new KeyValuePair<string, IReadOnlyList<string>>(string.Empty, Array.Empty<string>());
}

if (!parameterToCheck.Matches(current, out var isFatal, searchOptions))
{
if (isFatal)
Expand Down

0 comments on commit 95d8840

Please sign in to comment.