Skip to content
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

Fix enumerator bug #22

Merged
merged 2 commits into from
Nov 14, 2023
Merged
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
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
Loading