Skip to content

Commit

Permalink
Properly fix #158
Browse files Browse the repository at this point in the history
Old fix would sometimes cause the navigation system to stop working
  • Loading branch information
justalemon committed May 24, 2024
1 parent 581ef4d commit 44e6e2e
Showing 1 changed file with 16 additions and 26 deletions.
42 changes: 16 additions & 26 deletions LemonUI/Menus/NativeMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1802,34 +1802,29 @@ public void Previous()
}

int initialIndex = SelectedIndex;
int nextIndex = initialIndex;
int nextIndex = SelectedIndex;

nextIndex -= 1;

while (true)
{
if (nextIndex == initialIndex)
{
return;
}

nextIndex -= 1;

if (nextIndex < 0)
{
nextIndex = Items.Count - 1;
}

if (Items[nextIndex] is NativeSeparatorItem)
if (nextIndex == initialIndex)
{
continue;
return;
}

if (nextIndex == SelectedIndex)
if (Items[nextIndex] is not NativeSeparatorItem)
{
SelectedIndex = nextIndex;
return;
}

SelectedIndex = nextIndex;
return;
nextIndex -= 1;
}
}
/// <summary>
Expand All @@ -1844,34 +1839,29 @@ public void Next()
}

int initialIndex = SelectedIndex;
int nextIndex = initialIndex;
int nextIndex = SelectedIndex;

nextIndex += 1;

while (true)
{
if (nextIndex == initialIndex)
{
return;
}

nextIndex += 1;

if (nextIndex >= Items.Count)
{
nextIndex = 0;
}

if (Items[nextIndex] is NativeSeparatorItem)
if (nextIndex == initialIndex)
{
continue;
return;
}

if (nextIndex == SelectedIndex)
if (Items[nextIndex] is not NativeSeparatorItem)
{
SelectedIndex = nextIndex;
return;
}

SelectedIndex = nextIndex;
return;
nextIndex += 1;
}
}

Expand Down

0 comments on commit 44e6e2e

Please sign in to comment.