This is a backport of a bugfix in pensieve.love. It's not technically a bug here in lines.love, but it seems worth establishing an architectural invariant (or rather lack of invariant).
LÖVE's standard event loop performs the following sequence of operations in a single frame:
Ideally any mutations to global state happen during the first two phases, while drawing includes no mutation.
However, there is a special case: starty
, the top y coordinate for
each each line in the editor. This is used all over the place, and the
cheapest way to compute it is to simply save it while drawing.
However, draw by definition only updates starty
for lines that are
drawn on screen. To avoid stale data on lines off screen, say after
scrolling, events often clear starty
for all lines, leaving it to the
next draw phase to repopulate the right lines.
Sandwiched between the above two "however"s, the update phase needs to
gracefully handle starty
being nil in the occasional frame right after
an event.
I think I've audited all our uses of starty
, and this commit fixes the
only place that violates this rule.
TZJGPNVSP2R47WQMCBNEQDG53VEBFXPYTZEXRUYCCGOBFTKBNF3QC