chiark / gitweb /
Fix panic when extending an empty feed.
authorSimon Tatham <anakin@pobox.com>
Thu, 11 Jan 2024 07:59:02 +0000 (07:59 +0000)
committerSimon Tatham <anakin@pobox.com>
Thu, 11 Jan 2024 08:04:10 +0000 (08:04 +0000)
commit7aac75c11ce41fdfc16fe927e99ddb4376325d87
tree2e9e866753a1af9e83a4c22889c5a8d9a30312b1
parent875a0fa3c8d9d1a55b5344a2349bbc63203f4ab5
Fix panic when extending an empty feed.

If a file contains nothing but a header and an extensible indicator,
and you press [0] to extend, and that attempt to fetch more items
fails, then the extensible indicator vanishes, and is removed from the
file's list of items. So the 2-line header moves forward one index
slot, into the place where the 3-line indicator was. But on any but
the tiniest screen, your current position was surely on the last line
of the indicator - so now it's out of range of the item now in that
position.

To fix this, I've added a new position fixup function, which is called
whenever we fear our line position might be outside the bounds of the
item it's in. This is called after try_extend, where the problem
actually showed up; it's also called on resize(), in case a file is
newly constructed but one of the statuses in it has been updated from
the server since we last visited.
src/file.rs