Skip to content
Open
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: 13 additions & 1 deletion src/BizHawk.Client.Common/config/Binding.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using System.Collections.Generic;
#if DEBUG
using System.Diagnostics;
#endif
using System.Linq;

namespace BizHawk.Client.Common
Expand Down Expand Up @@ -132,7 +135,7 @@ void Bind(string tabGroup, string displayName, string defaultBinding = "", strin
Bind("TAStudio", "Delete Branch", "Alt+Delete");
Bind("TAStudio", "Show Cursor");
Bind("TAStudio", "Toggle Follow Cursor", "Shift+F");
Bind("TAStudio", "Toggle Auto-Restore", "Shift+R");
Bind("TAStudio", "Toggle Auto-Restore", "Alt+R");
Bind("TAStudio", "Seek To Green Arrow", "R");
Bind("TAStudio", "Toggle Turbo Seek", "Shift+S");
Bind("TAStudio", "Undo", "Ctrl+Z"); // TODO: these are getting not unique enough
Expand Down Expand Up @@ -198,6 +201,15 @@ void Bind(string tabGroup, string displayName, string defaultBinding = "", strin

AllHotkeys = dict;
Groupings = dict.Values.Select(static info => info.TabGroup).Distinct().ToList();

#if DEBUG
var bindings = dict.Values
.Where(static info => !info.DisplayName.StartsWith("RA ") && !string.IsNullOrEmpty(info.DefaultBinding))
.Select(static info => info.DefaultBinding);
#pragma warning disable MA0031 // Optimize Enumerable.Count() usage
Debug.Assert(bindings.Count() == bindings.Distinct().Count(), "Do not default bind multiple hotkeys to the same button combination.");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The actual problem here is that this is a double enumeration. Enumerate .ToArray() first.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the double enumeration? I enumerate bindings twice, but doing a ToArray won't change that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

double/multiple enumeration

Looks like the built-in diagnostic for catching those wasn't actually enabled...

#pragma warning restore MA0031 // Optimize Enumerable.Count() usage
#endif
}

public static void ResolveWithDefaults(IDictionary<string, string> dict)
Expand Down