This has been broken since commit b544e8c357 on May 17 :/ I'm just undoing that commit, which turns out to be completely unnecessary. And adding a test.
FFBIY74NM7CMGTVYDMEFOTE2PY5E5TMACASQRK5OXRBGN4B4GTCAC
DRFE3B3ZKRG4RY2R5Q3SDFD3LH4EXUX3CZCDFBNAXVI2SLDS57PAC
CRYGI3LRKVHD4D76Q2VTNSX4B2JP5FPDEFJU6DBO7QWFHER2E4OQC
IDG26SXKRKPRUQM3G2MMBQR3UZGNU7NCWJBBDKKIM5IGUNJQ2URQC
OTIBCAUJ3KDQJLVDN3A536DLZGNRYMGJLORZVR3WLCGXGO6UGO6AC
G3C4FKPRNQ35BW3YU2RAON6O2HZBLIVDASR6VP5BU4I4L37K24PAC
JFFUF5ALUWPDM7IEDEZVAYG2SVXO334STONRGKVB3QKY2TT5QGBQC
252M2QMDBMNWHBZY5MDSC7WVYO5JBLJYPVMW5W4IVJCZVYRQ5IQQC
VCMS2CWTJDOW2FYCDH4ZSMVJAP6W4ZV4VWHJPPGGNHRX47GWYAGAC
K2X6G75Z6XBC4DVIRWC5HC7XA3A2SKOM3MWSQTCFEYWIJL7LME2QC
SRVDX4I5QKWAH3Y5DX25PG34U7NY55H46ZYG2APH47BUZT3EJ2HAC
BLWAYPKV3MLDZ4ALXLUJ25AIR6PCIL4RFYNRYLB26GFVC2KQBYBAC
6DE7RBZ6RHNEICJ7EUMCTROK43LW4LYINULIF2QEQOKCXWLUYUXAC
XNFTJHC4QSHNSIWNN7K6QZEZ37GTQYKHS4EPNSVPQCUSWREROGIQC
WTDKUACNTWB4KD34TZZNPILNX4FQ6MR64XYBAA5GOMICF73WLIAAC
end
function test_cancel_stroke()
io.write('\ntest_cancel_stroke')
-- display a drawing followed by a line of text (you shouldn't ever have a drawing right at the end)
Filename = 'foo'
App.screen.init{width=Margin_width+256, height=300} -- drawing coordinates 1:1 with pixels
Lines = load_array{'```lines', '```', ''}
Current_drawing_mode = 'line'
App.draw()
check_eq(#Lines, 2, 'F - test_cancel_stroke/baseline/#lines')
check_eq(Lines[1].mode, 'drawing', 'F - test_cancel_stroke/baseline/mode')
check_eq(Lines[1].y, Margin_top+Drawing_padding_top, 'F - test_cancel_stroke/baseline/y')
check_eq(Lines[1].h, 128, 'F - test_cancel_stroke/baseline/y')
check_eq(#Lines[1].shapes, 0, 'F - test_cancel_stroke/baseline/#shapes')
-- start drawing a line
App.run_after_mouse_press(Margin_left+5, Margin_top+Drawing_padding_top+6, 1)
-- cancel
App.run_after_keychord('escape')
App.run_after_mouse_release(Margin_left+35, Margin_top+Drawing_padding_top+36, 1)
local drawing = Lines[1]
check_eq(#drawing.shapes, 0, 'F - test_cancel_stroke/#shapes')