Scenario:
function car.draw() error('a') end
Before this commit, Carousel crashed with this error: Error: text.lua:739: attempt to compare nil with number stack traceback: text.lua:739: in function 'nearest_cursor_pos' text.lua:470: in function 'down' edit.lua:265: in function 'mouse_wheel_move' on.mouse_wheel_move:6: in function 'mouse_wheel_move' main.lua:198: in function <main.lua:195> app.lua:35: in function <app.lua:35> app.lua:179: in function <app.lua:170> [C]: in function 'xpcall' app.lua:198: in function <app.lua:197> [C]: in function 'xpcall'
The code in text.lua involves a comparison to State.cursor_x, which is nil.
I don't quite understand why cursor_x isn't set only in this narrow situation and works fine with regular prints like in my second example screen called 'print'. Even this code scrolls fine with the mouse wheel:
for i=1,10 do print(i) end -- just to make the window scroll
error('a')
But this runs into our bug:
for i=1,10 do print(i) end
function car.draw() error('a') end
VEHR6IYD4PJ5WYVTDZ2VWDHD4WVFPKP6UTBAYKG27OQ6LYOQHKWQC