scenario: paste enough text that the note needs to scroll Before this commit the cursor would end up outside the viewport and crash.
Turns out my experiments of commit 93683450a4 (Dec 24) and commit 926c66a908 (Dec 21) were connected. I need the latter precisely because I need the former.
Summary: 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 causes it to scroll too much. I have a little tweak to detect such situations and not use the editor's scrolling logic. But if I don't use the editor's scrolling logic I also shouldn't pretend I did.
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 it make any heuristic choices it likes as long as it communicates accurately with the outside whether it changed the global viewport.
One open question here: if I do my tweak it pans the viewport anyway. So why does it matter whether the outside does or not? There must be a discrepancy in bring_cursor_into_view that this commit is patching over. And I do see that comment in bring_cursor_into_view suggesting all is not right with it. It was introduced in commit 1ee1cbab6.
I'll come back again:
37AATGG5QIXOBXWA3DMSVMIIDSULA36NPETHOYZIOZ4G4RZLMHCAC
AHOO2ILEJWTPCYHJH26WAF7A4YYVMHFX4UWHSAAAMHI73TSQZ6CAC
AAYK7CECIP4352RGBPFBV52XUKI6YECVJN24PVCN4FG4NW7NQLKAC
KTABGWEVR6D5KLOCVAOUDNQMRB3BUFU4GTR3OIAWLJSIPIG6G46QC
JMUE7GSN6QDQZ6NDRB55MRJMKJN6LBD6MVQPKROYPDOIXM7I3XNQC
KKMFQDR43ZWVCDRHQLWWX3FCWCFA3ZSXYOBRJNPHUQZR2XPKWULAC
UAX3KJOIN3XBSLKP4IAWAWSCI3DLDKF22A6HRMGA4FHY3AS2QRVAC
VPCPK52KMU4MZUXP4SUSJJDEHDR4C3KJ45HLMUQUK32FMY6OCQ4QC
EAHBVX4JVOMSJCMHLOMB6GWTWQNMKVXMPONA7L4KDVH3YFX7EZKAC
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
-- updating screen_top1 can be jarring if the pane had room above it on screen
-- the editor widget thinks the screen is small and can scroll overly much
-- prefer to pan the surface when possible
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
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
end
return screen_top_updated