Skip to content

Commit

Permalink
fix - Fixed cancellation crash
Browse files Browse the repository at this point in the history
---

We've fixed a crash when trying to cancel the selection input styles.

---

Type: fix
Breaking: False
Doc Required: False
Part: 1/1
  • Loading branch information
AptiviCEO committed Apr 20, 2024
1 parent 85df1ab commit bc7676b
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 44 deletions.
25 changes: 14 additions & 11 deletions Terminaux/Inputs/Styles/Infobox/InfoBoxSelectionColor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -709,19 +709,22 @@ void UpdatePositionBasedOnMouse(PointerEventContext mouse)
}

// Verify that the current position is not a disabled choice
while (selections[currentSelection].ChoiceDisabled)
if (currentSelection >= 0)
{
if (goingUp)
while (selections[currentSelection].ChoiceDisabled)
{
currentSelection--;
if (currentSelection < 0)
currentSelection = selections.Length - 1;
}
else
{
currentSelection++;
if (currentSelection > selections.Length - 1)
currentSelection = 0;
if (goingUp)
{
currentSelection--;
if (currentSelection < 0)
currentSelection = selections.Length - 1;
}
else
{
currentSelection++;
if (currentSelection > selections.Length - 1)
currentSelection = 0;
}
}
}
}
Expand Down
25 changes: 14 additions & 11 deletions Terminaux/Inputs/Styles/Infobox/InfoBoxSelectionMultipleColor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -733,19 +733,22 @@ void UpdatePositionBasedOnMouse(PointerEventContext mouse)
}

// Verify that the current position is not a disabled choice
while (selections[currentSelection].ChoiceDisabled)
if (currentSelection >= 0)
{
if (goingUp)
while (selections[currentSelection].ChoiceDisabled)
{
currentSelection--;
if (currentSelection < 0)
currentSelection = selections.Length - 1;
}
else
{
currentSelection++;
if (currentSelection > selections.Length - 1)
currentSelection = 0;
if (goingUp)
{
currentSelection--;
if (currentSelection < 0)
currentSelection = selections.Length - 1;
}
else
{
currentSelection++;
if (currentSelection > selections.Length - 1)
currentSelection = 0;
}
}
}
}
Expand Down
25 changes: 14 additions & 11 deletions Terminaux/Inputs/Styles/Selection/SelectionMultipleStyle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -479,19 +479,22 @@ void UpdateSelectedIndexWithMousePos(PointerEventContext mouse)
}

// Verify that the current position is not a disabled choice
while (AllAnswers[HighlightedAnswer - 1].ChoiceDisabled)
if (HighlightedAnswer > 0)
{
if (goingUp)
{
HighlightedAnswer--;
if (HighlightedAnswer == 0)
HighlightedAnswer = AllAnswers.Count;
}
else
while (AllAnswers[HighlightedAnswer - 1].ChoiceDisabled)
{
HighlightedAnswer++;
if (HighlightedAnswer > AllAnswers.Count)
HighlightedAnswer = 1;
if (goingUp)
{
HighlightedAnswer--;
if (HighlightedAnswer == 0)
HighlightedAnswer = AllAnswers.Count;
}
else
{
HighlightedAnswer++;
if (HighlightedAnswer > AllAnswers.Count)
HighlightedAnswer = 1;
}
}
}

Expand Down
25 changes: 14 additions & 11 deletions Terminaux/Inputs/Styles/Selection/SelectionStyle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -449,19 +449,22 @@ public static int PromptSelection(string Question, InputChoiceInfo[] Answers, In
}

// Verify that the current position is not a disabled choice
while (AllAnswers[HighlightedAnswer - 1].ChoiceDisabled)
if (HighlightedAnswer > 0)
{
if (goingUp)
{
HighlightedAnswer--;
if (HighlightedAnswer == 0)
HighlightedAnswer = AllAnswers.Count;
}
else
while (AllAnswers[HighlightedAnswer - 1].ChoiceDisabled)
{
HighlightedAnswer++;
if (HighlightedAnswer > AllAnswers.Count)
HighlightedAnswer = 1;
if (goingUp)
{
HighlightedAnswer--;
if (HighlightedAnswer == 0)
HighlightedAnswer = AllAnswers.Count;
}
else
{
HighlightedAnswer++;
if (HighlightedAnswer > AllAnswers.Count)
HighlightedAnswer = 1;
}
}
}

Expand Down

0 comments on commit bc7676b

Please sign in to comment.