scenario: paste enough text that the note needs to scroll Before this commit the cursor would end up outside the viewport and crash.
The editor widget was originally implemented in isolation, to take over the whole window (App.screen). If it starts low down the window it assumes it's always going to have just a few lines of height to work with. That can cause it to scroll too much and seem jarring at times. I have a special case in maybe_update_screen_top_of_cursor_pane to detect such situations and not use the editor's scrolling logic. I need to update the cursor pane's screen_top when the special case triggers.
Another way to put it: The decision of when to adjust the global viewport from within a single editor buffer can get intricate. We'll let maybe_update_screen_top_of_cursor_pane make any heuristic choices it likes as long as it communicates accurately with the outside whether it changed the global viewport.
Regression introduced in commit 926c66a908.
Attempt #1: commit b1c26e98a. This commit doesn't change my logic, just gives git blame a clean starting point.
4WAZ3E5BASY4GJDS5XNDRPHD4S4NVKRWHYOSFT6EXRTMM7Y5EKPAC
3U6YMMN2GMRL27TLPE7V3KUGM6MI2L3SAQSNU6HMNRINVXVRL3QAC
AHOO2ILEJWTPCYHJH26WAF7A4YYVMHFX4UWHSAAAMHI73TSQZ6CAC
GR4RROJFJOGM2WLQSVK5R5UYD7IK6ITF6UP5RVHAHD3J4OFJWGCAC
KKMFQDR43ZWVCDRHQLWWX3FCWCFA3ZSXYOBRJNPHUQZR2XPKWULAC
JMUE7GSN6QDQZ6NDRB55MRJMKJN6LBD6MVQPKROYPDOIXM7I3XNQC
UAX3KJOIN3XBSLKP4IAWAWSCI3DLDKF22A6HRMGA4FHY3AS2QRVAC
VPCPK52KMU4MZUXP4SUSJJDEHDR4C3KJ45HLMUQUK32FMY6OCQ4QC
KTABGWEVR6D5KLOCVAOUDNQMRB3BUFU4GTR3OIAWLJSIPIG6G46QC
37AATGG5QIXOBXWA3DMSVMIIDSULA36NPETHOYZIOZ4G4RZLMHCAC
if eq(old_top, {line=1, pos=1}) and pane.top > Header_height and cursor_sy - Display_settings.y > App.screen.height - Header_height - Line_height then
if not eq(old_top, pane.screen_top1) and eq(old_top, {line=1, pos=1}) and pane.top > Header_height and cursor_sy - Display_settings.y > App.screen.height - Header_height - Line_height then
return
return false -- bring_cursor_of_cursor_pane_in_view updated Display_settings.y but not pane.screen_top1
end
local screen_top_updated = not eq(old_top, pane.screen_top1)
if screen_top_updated then
Display_settings.y = up_edge_sy(Cursor_pane.col, Cursor_pane.row) + y_of_schema1(pane, pane.screen_top1)
Surface.cursor_on_screen_check = true -- cursor was on screen before keystroke, so it should remain on screen after