Skip to content

Commit 4decf9c

Browse files
style(ui): add explicit parentheses for arithmetic precedence
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: JasonXuDeveloper - 傑 <jason@xgamedev.net>
1 parent 8604273 commit 4decf9c

File tree

2 files changed

+3
-3
lines changed
  • UnityProject/Packages/com.jasonxudeveloper.jengine.ui

2 files changed

+3
-3
lines changed

UnityProject/Packages/com.jasonxudeveloper.jengine.ui/Editor/Components/Navigation/JTabView.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public JTabView AddTab(string label, VisualElement content)
125125
if (_maxTabsPerRow > 0)
126126
{
127127
// Reduce basis to account for per-tab margins; flexGrow fills remaining space
128-
var percent = (100f - _maxTabsPerRow * 2f) / _maxTabsPerRow;
128+
var percent = (100f - (_maxTabsPerRow * 2f)) / _maxTabsPerRow;
129129
tabButton.style.flexBasis = new StyleLength(new Length(percent, LengthUnit.Percent));
130130
tabButton.style.flexGrow = 1;
131131
tabButton.style.flexShrink = 1;

UnityProject/Packages/com.jasonxudeveloper.jengine.ui/Tests/Editor/Components/Navigation/JTabViewTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ public void AddTab_WithMaxTabsPerRow_SetsFlexBasisPercent()
484484
// (100 - 3*2) / 3 = 31.33...%
485485
var basis = tabButton.style.flexBasis; // StyleLength
486486
Assert.AreEqual(LengthUnit.Percent, basis.value.unit);
487-
Assert.AreEqual((100f - 3f * 2f) / 3f, basis.value.value, 0.01f);
487+
Assert.AreEqual((100f - (3f * 2f)) / 3f, basis.value.value, 0.01f);
488488
}
489489

490490
[Test]
@@ -520,7 +520,7 @@ public void AddTab_MaxTabsPerRow2_SetsCorrectBasis()
520520
var tabButton = bar[0] as Label;
521521

522522
// (100 - 2*2) / 2 = 48%
523-
Assert.AreEqual((100f - 2f * 2f) / 2f, tabButton.style.flexBasis.value.value, 0.01f);
523+
Assert.AreEqual((100f - (2f * 2f)) / 2f, tabButton.style.flexBasis.value.value, 0.01f);
524524
}
525525

526526
#endregion

0 commit comments

Comments
 (0)