diff --git a/LemonUI/Menus/NativeMenu.cs b/LemonUI/Menus/NativeMenu.cs index 2e0e92f..49acdd6 100644 --- a/LemonUI/Menus/NativeMenu.cs +++ b/LemonUI/Menus/NativeMenu.cs @@ -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; } } /// @@ -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; } }