Don't switch to invisible first/last room on Ctrl+PgUp/PgDn
If you're on the first visible room and try to switch to the previous one (or on the last visible room switching to the next one), the first (or last) room in the list is incorrectly selected even if it's not currently visible. Fix this by not first entering each room and then checking whether it is the one we really wanted, but iterating until we find a room that we want and only entering it then.
This commit is contained in:
@@ -132,17 +132,25 @@ Kirigami.ScrollablePage {
|
||||
}
|
||||
|
||||
function goToNextRoom() {
|
||||
do {
|
||||
listView.incrementCurrentIndex();
|
||||
} while (!listView.currentItem.visible && listView.currentIndex !== listView.count - 1)
|
||||
listView.currentItem.action.trigger();
|
||||
let index = listView.currentIndex;
|
||||
while (index++ !== listView.count - 1) {
|
||||
if (listView.itemAtIndex(index).visible) {
|
||||
listView.currentIndex = index;
|
||||
listView.currentItem.action.trigger();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function goToPreviousRoom() {
|
||||
do {
|
||||
listView.decrementCurrentIndex();
|
||||
} while (!listView.currentItem.visible && listView.currentIndex !== 0)
|
||||
listView.currentItem.action.trigger();
|
||||
let index = listView.currentIndex;
|
||||
while (index-- !== 0) {
|
||||
if (listView.itemAtIndex(index).visible) {
|
||||
listView.currentIndex = index;
|
||||
listView.currentItem.action.trigger();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
titleDelegate: collapsedMode ? empty : searchField
|
||||
|
||||
Reference in New Issue
Block a user