fix a regression in line wrapping

[?]
May 28, 2022, 4:02 PM
R5OKMVVCPAKL2IUMIY7A7ZMTJQZS6UWKW4EVLAVCPLPVNI5DCEYQC

Dependencies

Change contents

  • edit in text.lua at line 118
    [2.660]
    [2.660]
    function test_draw_word_wrapping_text()
    io.write('\ntest_draw_word_wrapping_text')
    App.screen.init{width=60, height=60}
    Lines = load_array{'abc def ghi', 'jkl'}
    Line_width = App.screen.width
    Cursor1 = {line=1, pos=1}
    Screen_top1 = {line=1, pos=1}
    Screen_bottom1 = {}
    Zoom = 1
    App.draw()
    local screen_top_margin = 15 -- pixels
    local line_height = 15 -- pixels
    local y = screen_top_margin
    App.screen.check(y, 'abc ', 'F - test_draw_word_wrapping_text/screen:1')
    y = y + line_height
    App.screen.check(y, 'def ', 'F - test_draw_word_wrapping_text/screen:2')
    y = y + line_height
    App.screen.check(y, 'ghi', 'F - test_draw_word_wrapping_text/screen:3')
    end
    function test_draw_text_wrapping_within_word()
    -- arrange a screen line that needs to be split within a word
    io.write('\ntest_draw_text_wrapping_within_word')
    App.screen.init{width=60, height=60}
    Lines = load_array{'abcd e fghijk', 'xyz'}
    Line_width = App.screen.width
    Cursor1 = {line=1, pos=1}
    Screen_top1 = {line=1, pos=1}
    Screen_bottom1 = {}
    Zoom = 1
    App.draw()
    local screen_top_margin = 15 -- pixels
    local line_height = 15 -- pixels
    local y = screen_top_margin
    App.screen.check(y, 'abcd ', 'F - test_draw_text_wrapping_within_word/screen:1')
    y = y + line_height
    App.screen.check(y, 'e fghi', 'F - test_draw_text_wrapping_within_word/screen:2')
    y = y + line_height
    App.screen.check(y, 'jk', 'F - test_draw_text_wrapping_within_word/screen:3')
    end
  • edit in text.lua at line 784
    [3.493][3.6703:6796]()
    assert(25 + frag_width > line_width) -- avoid infinite loop when window is too narrow
  • edit in text.lua at line 785
    [3.536]
    [3.536]
    --? print(x, frag, frag_width, line_width)
  • edit in text.lua at line 791
    [3.6916]
    [3.738]
    assert(b > 0) -- avoid infinite loop when window is too narrow
  • edit in text.lua at line 811
    [3.1557]
    [3.1557]
    x = x + frag_width