The sequence of events is as follows:
Now drawing from the new pane.top no longer draws the screen line with the cursor, where the old one would have. And this can happen with just a few pixels of difference. You had x pixels of slack when you set screen_top. If plan_draw just adjusts things by more than x pixels, game over.
I should give up programming and become a hermit, for getting myself into this situation with so much promiscuously mutating global state.
IFGHOCUOIAKC722BNCIRNE2EDMGF77FBTYS57H5UWN6YXOLSZHQQC
BY5KI4F7BGHH4GUNHWG6Q7A3JD7GK5PYAOKLBWM4OBDV2OZVRAHQC
A76AOSKCKOQL5ZGYGWCGNRCMKLUTKGCDVJ5G3ELTIVHZ7OFH35MQC
Z5HLXU4PJWWJJDBCK52NBD6PIRIA3TAN2BKZB5HBYFGIDBX4F5HAC
QBL4YDQ5QC4MZ7RFS4ZSEBPN5WATAJ7UQLUPTXDUMXAMGBGQDOOQC
BULPIBEGL7TMK6CVIE7IS7WGAHGOSUJBGJSFQK542MOWGHP2ADQQC
MXA3RZYKUI4UF2ISY7JEF6VKX6NOPZMZH5SLLCZHRJKFIXXXDPSAC
SVJZZDC3K6AKAXHGRNAZKRE2ZXEKJANNLG7LSSUZJARFBL5F7C4AC
KOTI3MFGQ4PDS4I75JIJG734LTET6745VGTSMNFYYASVIO6H2KPAC
3OKKTUT4Q7W44JHILOFV5BVUA7ZOBIHBCEXGZ65CPXV4PRLI2W4QC
QCPXQ2E3USF3Z6R6WJ2JKHTRMPKA6QWXFKKRMLXA3MXABJEL543AC
TGZAJUEFRK3NTCDMPIIG7U2TGLDHK4U3JDNFAYX7NHXTJYBYEZIAC
UHB4GARJI5AB5UCDCZRFSCJNXGJSLU5DYGUGX5ITYEXI7Q43Z4CAC
B22JHH4W75CLJTHZWAHJZWYL3L7IN4MSIJSR5CCCCXYWYA27TRNQC
S4TFD5YYEMH24RVOO5THEOW7WUP4FSICR4UYABSRE2UKXYCNN4DQC
OTIBCAUJ3KDQJLVDN3A536DLZGNRYMGJLORZVR3WLCGXGO6UGO6AC
CZY3IDERLI6MTKKKMX6QLLERSPM2ZJ57NGQRKILJBM7S5PYPQ3XAC
2L5MEZV344TOZLVY3432RHJFIRVXFD6O3GWLL5O4CV66BGAFTURQC
LNUHQOGHIOFGJXNGA3DZLYEASLYYDGLN2I3EDZY5ANASQAHCG3YQC
SPTL7VK47SAGTCGQDCQWMEFC43KWJNWCL76NSYHEVBENHIWKRWNAC
ZUVS2754WHE4L3SMNFKGY5ZVBTIXUCYD3OVPDJBQM3AKPHSPMC3QC
GQBUV2XOMEPMTXMPCBQWGGIUXGQDX77VTGPFIG6YT7G64ASOYHXQC
print('down', State.cursor1.line, State.cursor1.pos, State.screen_top1.line, State.screen_top1.pos, State.screen_bottom1.line, State.screen_bottom1.pos)
print('down', State.screen_top1.line, State.screen_top1.pos, State.cursor1.line, State.cursor1.pos, State.screen_bottom1.line, State.screen_bottom1.pos)
if pane.cursor_x >= 0 and pane.cursor_x < App.screen.width and pane.cursor_y >= Header_height and pane.cursor_y < App.screen.height then
add_hotkey_to_menu('ctrl+e: stop editing')
add_hotkey_to_menu('ctrl+h on drawing: help')
add_hotkey_to_menu('ctrl+f: find')
add_hotkey_to_menu('alt+left alt+right: prev/next word')
add_hotkey_to_menu('ctrl+z ctrl+y: undo/redo')
add_hotkey_to_menu('ctrl+x ctrl+c ctrl+v: cut/copy/paste')
else
add_panning_hotkeys_to_menu()
end
--? if pane.cursor_x >= 0 and pane.cursor_x < App.screen.width and pane.cursor_y >= Header_height and pane.cursor_y < App.screen.height then
--? add_hotkey_to_menu('ctrl+e: stop editing')
--? add_hotkey_to_menu('ctrl+h on drawing: help')
--? add_hotkey_to_menu('ctrl+f: find')
--? add_hotkey_to_menu('alt+left alt+right: prev/next word')
--? add_hotkey_to_menu('ctrl+z ctrl+y: undo/redo')
--? add_hotkey_to_menu('ctrl+x ctrl+c ctrl+v: cut/copy/paste')
--? else
--? add_panning_hotkeys_to_menu()
--? end