bugfix

[?]
May 24, 2022, 9:34 PM
DFSDPDO7RHOLPVT4TD2Z3YZCKS6737LYIWBTJJI4BO73IIAJ5BYQC

Dependencies

  • [2] 4RUI5X52 a few tests for pageup, and a bugfix
  • [3] 76AIXR7H bugfix
  • [4] QYIFOHW3 first test!
  • [5] S5VCAFKY couple of tests for cursor down
  • [6] IMEJA43L snapshot
  • [7] HYEAFRZ2 split mouse_pressed events between Text and Drawing
  • [8] H2DPLWMV snapshot: wrapping long lines at word boundaries
  • [9] DAENUOGV eliminate assumptions that line length == size in bytes
  • [10] BULPIBEG beginnings of a module for the text editor
  • [11] 5Q6NIG66 bugfix
  • [*] R53OF3ON one bug I've repeatedly run into while testing with Moby Dick

Change contents

  • replacement in text.lua at line 209
    [3.1233][3.761:838]()
    check_eq(Screen_top1.line, 1, 'F - test_up_arrow_moves_cursor/screen_top')
    [3.1233]
    [3.838]
    check_eq(Screen_top1.line, 1, 'F - test_down_arrow_moves_cursor/screen_top')
  • edit in text.lua at line 442
    [13.1842]
    [2.1]
    function test_up_arrow_scrolls_up_to_empty_line()
    io.write('\ntest_up_arrow_scrolls_up_from_empty_line')
    -- display a screenful of text with an empty line just above it outside the screen
    App.screen.init{width=120, height=60}
    Lines = load_array{'', 'abc', 'def', 'ghi', 'jkl'}
    Line_width = 120
    Cursor1 = {line=2, pos=1}
    Screen_top1 = {line=2, pos=1}
    Screen_bottom1 = {}
    Zoom = 1
    local screen_top_margin = 15 -- pixels
    local line_height = math.floor(15*Zoom) -- pixels
    App.draw()
    local y = screen_top_margin
    App.screen.check(y, 'abc', 'F - test_up_arrow_scrolls_up_from_empty_line/baseline/screen:1')
    y = y + line_height
    App.screen.check(y, 'def', 'F - test_up_arrow_scrolls_up_from_empty_line/baseline/screen:2')
    y = y + line_height
    App.screen.check(y, 'ghi', 'F - test_up_arrow_scrolls_up_from_empty_line/baseline/screen:3')
    -- after hitting the up arrow the screen scrolls up by one line
    App.run_after_keychord('up')
    check_eq(Screen_top1.line, 1, 'F - test_up_arrow_scrolls_up_from_empty_line/screen_top')
    check_eq(Cursor1.line, 1, 'F - test_up_arrow_scrolls_up_from_empty_line/cursor')
    y = screen_top_margin
    -- empty first line
    y = y + line_height
    App.screen.check(y, 'abc', 'F - test_up_arrow_scrolls_up_from_empty_line/screen:2')
    y = y + line_height
    App.screen.check(y, 'def', 'F - test_up_arrow_scrolls_up_from_empty_line/screen:3')
    end
  • replacement in text.lua at line 955
    [3.844][3.1:19]()
    --? print('--')
    [3.476]
    [3.19]
    --? print('-- nearest', x)
  • edit in text.lua at line 957
    [3.35]
    [3.870]
    --? print('nearest', x, '^'..line..'$', left, right)
    if left == right then
    return left
    end
  • replacement in text.lua at line 964
    [3.1010][3.36:92]()
    --? print(x, left, right, curr, currxmin, currxmax)
    [3.1010]
    [3.1010]
    --? print('nearest', x, left, right, curr, currxmin, currxmax)
  • replacement in text.lua at line 1012
    [3.1230][3.1230:1290]()
    local line_before_cursor = line_data:sub(1, cursor_pos-1)
    [3.1230]
    [3.1079]
    --? print(cursor_pos, #line_data, line_data)
    local cursor_offset = utf8.offset(line_data, cursor_pos)
    --? print(cursor_offset)
    assert(cursor_offset)
    local line_before_cursor = line_data:sub(1, cursor_offset-1)
  • replacement in text.lua at line 1022
    [3.3092][3.3092:3141]()
    local s_before_cursor = s:sub(1, cursor_pos-1)
    [3.3092]
    [3.1227]
    local cursor_offset = utf8.offset(s, cursor_pos)
    assert(cursor_offset)
    local s_before_cursor = s:sub(1, cursor_offset-1)