one bug I've repeatedly run into while testing with Moby Dick
[?]
May 24, 2022, 12:39 AM
R53OF3ONKT5VL5BGK63YSN6GXIIAVNYDG4UMHITK72WXFWPJ25MQCDependencies
- [2]
A2NV3WVOscrolling with up arrow - [3]
XOAHJ6M3similar tests for cursor up - [4]
PYGMASTVdisable some debug prints - [5]
IMEJA43Lsnapshot - [6]
C42QQZSFanother piece of support for line wrapping in cursor up - [7]
2RXZ3PGObeginning of a new approach to scroll+wrap - [8]
SVJZZDC3snapshot - no, that's all wrong - [*]
BULPIBEGbeginnings of a module for the text editor - [*]
YTSPVDZHfirst successful pagedown test, first bug found by test - [*]
PFT5Y2ZYmove - [*]
MGT5FTJ3first stab at supporting wrapping in cursor up - [*]
3CSIZJ33clearer comments - [*]
3QNOKBFMbeginnings of a test harness - [*]
AVTNUQYRbasic test-enabled framework
Change contents
- replacement in text.lua at line 359
-- display lines starting from the second screen line of line 3-- display lines starting from second screen line of a line - replacement in text.lua at line 374
-- after hitting the up arrow the screen scrolls up by one line-- after hitting the up arrow the screen scrolls up to first screen line - edit in text.lua at line 388
function test_up_arrow_scrolls_up_to_final_screen_line()print('test_up_arrow_scrolls_up_to_final_screen_line')-- display lines starting just after a long lineApp.screen.init{width=25+30, height=60}Lines = load_array{'abc def', 'ghi', 'jkl', 'mno'}Line_width = App.screen.widthCursor1 = {line=2, pos=1}Screen_top1 = {line=2, pos=1}Screen_bottom1 = {}Zoom = 1local screen_top_margin = 15 -- pixelslocal line_height = math.floor(15*Zoom) -- pixelsApp.draw()local y = screen_top_marginApp.screen.check(y, 'ghi', 'F - test_up_arrow_scrolls_up_to_final_screen_line/baseline/screen:1')y = y + line_heightApp.screen.check(y, 'jkl', 'F - test_up_arrow_scrolls_up_to_final_screen_line/baseline/screen:2')y = y + line_heightApp.screen.check(y, 'mno', 'F - test_up_arrow_scrolls_up_to_final_screen_line/baseline/screen:3')-- after hitting the up arrow the screen scrolls up to final screen line of previous lineApp.run_after_keychord('up')y = screen_top_marginApp.screen.check(y, 'def', 'F - test_up_arrow_scrolls_up_to_final_screen_line/screen:1')y = y + line_heightApp.screen.check(y, 'ghi', 'F - test_up_arrow_scrolls_up_to_final_screen_line/screen:2')y = y + line_heightApp.screen.check(y, 'jkl', 'F - test_up_arrow_scrolls_up_to_final_screen_line/screen:3')check_eq(Screen_top1.line, 1, 'F - test_up_arrow_scrolls_up_to_final_screen_line/screen_top')check_eq(Screen_top1.pos, 5, 'F - test_up_arrow_scrolls_up_to_final_screen_line/screen_top')check_eq(Cursor1.line, 1, 'F - test_up_arrow_scrolls_up_to_final_screen_line/cursor')check_eq(Cursor1.pos, 5, 'F - test_up_arrow_scrolls_up_to_final_screen_line/cursor')end - edit in text.lua at line 593
--? print('found previous text line') - edit in text.lua at line 595
Text.populate_screen_line_starting_pos(Cursor1.line) - edit in text.lua at line 601
--? print('has multiple screen lines') - edit in text.lua at line 603
--? print(#screen_line_starting_pos) - replacement in text.lua at line 606
if Screen_top1.line == Cursor1.line and Screen_top1.pos == screen_line_starting_pos thenif Screen_top1.line > Cursor1.line thenScreen_top1.line = Cursor1.line - edit in text.lua at line 923
function Text.populate_screen_line_starting_pos(line_index)-- duplicate some logic from Text.drawlocal line = Lines[line_index]if line.fragments == nil thenText.compute_fragments(line, Line_width)endlocal x = 25local pos = 1for _, f in ipairs(line.fragments) dolocal frag, frag_text = f.data, f.text--? print(x, frag)-- render fragmentlocal frag_width = math.floor(App.width(frag_text)*Zoom)if x + frag_width > Line_width thenx = 25if line.screen_line_starting_pos == nil thenline.screen_line_starting_pos = {1, pos}elsetable.insert(line.screen_line_starting_pos, pos)endendx = x + frag_widthlocal frag_len = utf8.len(frag)pos = pos + frag_lenendend - edit in app.lua at line 190[16.7197][16.7197]
--? print('checking for "'..expected_contents..'" at y '..tostring(y))