This seems to work when searching (on surface) for a line in a pane right up top containing only unwrapped lines.
Z575DEB7ULZXYH2BJCFXQMKPVXCSG72P46EHVBDD5PAOQTUDNZHQC
RATPLZ4GDOQQEXYSV523DEBGBL4YEYH7V7NWNZ5YMIXPHWOZCLLAC
6LBSEPBJTXIVBYX3AH5FYCQCN66ZRFFO3IVYMDS7IQUGEAZM3MHQC
NMSNEEDD5ENLSFCO4OYYRS5Z5YL2S554TGMI5IU42SIR2OIP6AOAC
DHI6IJCNSTHGED67T6H5X6Y636C7PIDGIJD32HBEKLT5WIMRS5MAC
HOSPP2ANSW654DYRTC6CQUQA2GUKV6T2FI7QBKXD2DZS3R32IMGAC
BULPIBEGL7TMK6CVIE7IS7WGAHGOSUJBGJSFQK542MOWGHP2ADQQC
HALS7E5UGKCP3DFY456F7Z3Y6WNGIABOCV2SHT34D5ZAGNCPV5PQC
LXTTOB33N2HCUZFIUDRQGGBVHK2HODRG4NBLH6RXRQZDCHF27BSAC
W5D22DQ5HRM3SGVEDY3E57Q6UPXGYLPQUJEVYMP2SU5KKG4J5K2AC
J3ER7DFO2TXYUMJAXZUFEHQNLFDNIXSYDTE7HEFGQ2RYB3A6RFPAC
OTIBCAUJ3KDQJLVDN3A536DLZGNRYMGJLORZVR3WLCGXGO6UGO6AC
EWK46OTWI2QK7ZZGYOCWWBHXHBXZQWR2FDW6LRTTKCN4K3ZFE5JAC
YKRUNSPXQMYUZM2HC2BWRL3OLVF5X3Y3XASG7JCT4TW4VUHZD6ZAC
TBRTM3AARI73LHUKOGIT66J5T3UTXQPJFLVJW7ZEBPZCOXAOGIIQC
TKAKGUAQBDJWK6DPAQC4JJYCAJFVCWNJMKBJIRDH2M3BGEZNSENAC
7AKT7IKOP6VQW3CABAVXCEZTHYNAETVXGFIQWB2L6I7LM7T57HAAC
HQCEHEHJXKH7ZU4OGLHT5QCY75YKPBH6WVSLXJKSQI4V7PKUBVEQC
UMRNXBPB2VOBLHHWVNFQDF5YYQ3IWYHSGFUTXURKYW4MZLPB33BQC
N44GTTQODVIWGKNWMN3TKY5DP7ATK2P6QMZCWRUC3XYGOESV77MAC
BJ5X5O4ACBBJ56LRBBSTCW6IBQP4HAEOOOPNH3SKTA4F66YTOIDAC
print(y_of_schema1(pane, pane.cursor1))
print('viewport starts at', Display_settings.y)
print('pane starts at', up_edge_sy(Cursor_pane.col, Cursor_pane.row))
--? local result = Padding_vertical
--? for i=1,Cursor_pane.row-1 do
--? print(i, result)
--? local pane = Surface[Cursor_pane.col][i]
--? result = result + Margin_above + height(pane) + Margin_below + Padding_vertical
--? end
print('cursor line contains ^'..pane.lines[pane.cursor1.line].data..'$')
print('cursor is at', y_of_schema1(pane, pane.cursor1), 'from top of pane')
Display_settings.y = cursor_sy + 3*Line_height - (App.screen.height - Header_height)
-- I don't understand why I need 4 line heights here.
-- Search bar is approximately 1.5 line heights. 3 should be plenty to
-- show the screen.
-- Doesn't matter what column it is on screen
print('cursor used to be at ', cursor_sy - Display_settings.y)
local old = Display_settings.y
print('subtract', App.screen.height, App.screen.height-Header_height)
--? Display_settings.y = cursor_sy - (App.screen.height - Header_height)
Display_settings.y = cursor_sy + Text.search_bar_height(pane) - (App.screen.height - Header_height)
--? Display_settings.y = cursor_sy + Line_height + Text.search_bar_height(pane) - (App.screen.height - Header_height)
print('=>', Display_settings.y)
print('cursor now at ', cursor_sy - Display_settings.y)
print('viewport height', App.screen.height)
print('cursor row starts', App.screen.height - (cursor_sy-Display_settings.y), 'px above bottom of viewport') -- totally wrong
assert(App.screen.height - (cursor_sy-Display_settings.y) > 1.5*Line_height)