Skip to content

Commit 57c2e6a

Browse files
committed
BufferListPanel: improve the first/last item detection logic
1 parent 199eafe commit 57c2e6a

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

ui/view/BufferListPanel.qml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,23 @@ Panel {
4242
property int lastIndex: -1
4343

4444
onContentYChanged: {
45-
// the index for section/network items is -1 => retain the previous index
4645
var first = indexAt(0, contentY + Theme.itemSizeExtraSmall)
46+
if (first === -1) {
47+
// the first item is a section item (a network delegate)
48+
var firstItem = contentItem.childAt(0, contentY + Theme.itemSizeExtraSmall)
49+
if (firstItem && firstItem.buffer)
50+
first = BufferModel.indexOf(firstItem.buffer)
51+
}
4752
if (first !== -1)
4853
firstIndex = first
54+
4955
var last = indexAt(0, contentY + height)
56+
if (last === -1) {
57+
// the last item is a section item (a network delegate)
58+
var lastItem = contentItem.childAt(0, contentY + height)
59+
if (lastItem && lastItem.buffer)
60+
last = BufferModel.indexOf(lastItem.buffer)
61+
}
5062
if (last !== -1)
5163
lastIndex = last
5264
}

0 commit comments

Comments
 (0)