Client for playing 300 publicly available Sokoban puzzles on a computer or phone.

bugfix for mouse wheel

Scenario:

  • Run the following code in Carousel:
    function car.draw() error('a') end
    
  • Run it. An error pops up in the output buffer.
  • Position the mouse over the output buffer and without any clicks scroll the mouse wheel.

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(&#x27;a&#x27;)

But this runs into our bug:

for i=1,10 do print(i) end
function car.draw() error(&#x27;a&#x27;) end

Created by  akkartik  on December 17, 2023
VEHR6IYD4PJ5WYVTDZ2VWDHD4WVFPKP6UTBAYKG27OQ6LYOQHKWQC
Change contents