Skip to content

Commit 4769538

Browse files
FIX: GetBindingDisplayString returns empty for composites filtered by group-based binding mask [UUM-141423]
Auto-generated by input-fix-pr-prep after input-fix-judge approved the hypothesis from input-fix-deep-dive (after triage Step 5b was rejected on pass 1). InputActionRebindingExtensions.GetBindingDisplayString(InputAction, InputBinding, InputBinding.DisplayStringOptions) returns empty when the binding mask filters by group, because the per-binding loop skips isPartOfComposite parts but then tests the mask against composite headers which carry no group metadata, so the whole composite drops out. Jira: https://issuetracker.unity3d.com/product/unity/issues/guid/UUM-141423 Judge rationale: file and method exist, the mechanism is in the method body (lines 321-323), the fall-through reuses the existing scan idiom at lines 444-448 of the same file with no signature/exception/serialization change, no nearby test asserts the buggy current behaviour, no native/threading/unsafe touches in the method or its direct callees at one level, and the previously-cited mixed-group composite edge case is now explicitly addressed via documented atomic-composite semantics grounded in the line-440-492 renderer's existing convention. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 0f3b085 commit 4769538

3 files changed

Lines changed: 38 additions & 1 deletion

File tree

Assets/Tests/InputSystem/CoreTests_Actions.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9238,6 +9238,21 @@ public void Actions_WhenGettingDisplayTextForBindingsOnAction_CompositesAreForma
92389238
Assert.That(action.GetBindingDisplayString(8), Is.EqualTo("Left Shift|Right Shift+A"));
92399239
}
92409240

9241+
// https://issuetracker.unity3d.com/product/unity/issues/guid/UUM-141423
9242+
[Test]
9243+
[Category("Actions")]
9244+
public void Actions_WhenGettingDisplayTextForBindingsOnAction_CompositeIsIncludedWhenAtLeastOnePartMatchesBindingMask()
9245+
{
9246+
var action = new InputAction();
9247+
9248+
action.AddCompositeBinding("1DAxis")
9249+
.With("Negative", "<Keyboard>/a", groups: "Keyboard")
9250+
.With("Positive", "<Keyboard>/d", groups: "Keyboard");
9251+
9252+
Assert.That(action.GetBindingDisplayString(InputBinding.MaskByGroup("Keyboard")),
9253+
Is.EqualTo("A/D"));
9254+
}
9255+
92419256
// https://fogbugz.unity3d.com/f/cases/1321175/
92429257
[Test]
92439258
[Category("Actions")]

Packages/com.unity.inputsystem/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
99

1010
### Fixed
1111

12+
- Fixed `InputActionRebindingExtensions.GetBindingDisplayString(InputAction, InputBinding, ...)` returning an empty string for composite bindings when the binding mask filters by group [UUM-141423](https://issuetracker.unity3d.com/product/unity/issues/guid/UUM-141423)
1213
- Fixed a `NullReferenceException` thrown when removing all action maps [UUM-137116](https://jira.unity3d.com/browse/UUM-137116)
1314
- Simplified default setting messaging by consolidating repetitive messages into a single HelpBox.
1415
- Fixed a `NullPointerReferenceException` thrown in `InputManagerStateMonitors.FireStateChangeNotifications` logging by adding validation [UUM-136095].

Packages/com.unity.inputsystem/InputSystem/Runtime/Actions/InputActionRebindingExtensions.cs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,28 @@ public static string GetBindingDisplayString(this InputAction action, InputBindi
321321
if (bindings[i].isPartOfComposite)
322322
continue;
323323
if (!bindingMask.Matches(bindings[i]))
324-
continue;
324+
{
325+
// Composites are filtered atomically: any matching part promotes the whole
326+
// composite, consistent with how the integer-index renderer at lines 440-492
327+
// already treats composites as one display unit; per-part filtering would
328+
// require a separate API.
329+
if (!bindings[i].isComposite)
330+
continue;
331+
var lastPartIndex = i + 1;
332+
while (lastPartIndex < bindings.Count && bindings[lastPartIndex].isPartOfComposite)
333+
++lastPartIndex;
334+
var anyPartMatches = false;
335+
for (var partIndex = i + 1; partIndex < lastPartIndex; ++partIndex)
336+
{
337+
if (bindingMask.Matches(bindings[partIndex]))
338+
{
339+
anyPartMatches = true;
340+
break;
341+
}
342+
}
343+
if (!anyPartMatches)
344+
continue;
345+
}
325346

326347
////REVIEW: should this filter out bindings that are not resolving to any controls?
327348

0 commit comments

Comments
 (0)