bugfix: up arrow when line above is a drawing

[?]
Feb 1, 2023, 6:39 AM
SWZAQHGRX3T5MZVM7YZ4EACZX5ON2NUZG5YXLWVEXLL3WZUZYAFQC

Dependencies

  • [2] ORRSP7FV deduce test names on failures
  • [3] Z5HLXU4P add state arg to a few functions
  • [4] ODLKHO7B switch to line index in a function
  • [5] LF7BWEG4 group all editor globals
  • [6] OI4FPFIN support drawings in the source editor
  • [7] SVJZZDC3 snapshot - no, that's all wrong
  • [8] KKMFQDR4 editing source code from within the app
  • [9] ZPUQSPQP extract a few methods
  • [10] V5MJRFOZ bugfix: down arrow doesn't scroll up unnecessarily
  • [*] LXTTOB33 extract a couple of files
  • [*] BULPIBEG beginnings of a module for the text editor

Change contents

  • edit in text_tests.lua at line 1056
    [2.9436]
    [12.11325]
    end
    function test_down_arrow_skips_drawing()
    -- some lines of text with a drawing intermixed
    local drawing_width = 50
    App.screen.init{width=Editor_state.left+drawing_width, height=100}
    Editor_state = edit.initialize_test_state()
    Editor_state.lines = load_array{'abc', -- height 15
    '```lines', '```', -- height 25
    'ghi'}
    Text.redraw_all(Editor_state)
    Editor_state.cursor1 = {line=1, pos=1}
    Editor_state.screen_top1 = {line=1, pos=1}
    Editor_state.screen_bottom1 = {}
    edit.draw(Editor_state)
    local y = Editor_state.top
    App.screen.check(y, 'abc', 'baseline/screen:1')
    y = y + Editor_state.line_height
    local drawing_height = Drawing_padding_height + drawing_width/2 -- default
    y = y + drawing_height
    App.screen.check(y, 'ghi', 'baseline/screen:3')
    check(Editor_state.cursor_x, 'baseline/cursor_x')
    -- after hitting the down arrow the cursor moves down by 2 lines, skipping the drawing
    edit.run_after_keychord(Editor_state, 'down')
    check_eq(Editor_state.cursor1.line, 3, 'cursor')
  • edit in text_tests.lua at line 1231
    [12.19428]
    [12.19428]
    function test_up_arrow_skips_drawing()
    -- some lines of text with a drawing intermixed
    local drawing_width = 50
    App.screen.init{width=Editor_state.left+drawing_width, height=100}
    Editor_state = edit.initialize_test_state()
    Editor_state.lines = load_array{'abc', -- height 15
    '```lines', '```', -- height 25
    'ghi'}
    Text.redraw_all(Editor_state)
    Editor_state.cursor1 = {line=3, pos=1}
    Editor_state.screen_top1 = {line=1, pos=1}
    Editor_state.screen_bottom1 = {}
    edit.draw(Editor_state)
    local y = Editor_state.top
    App.screen.check(y, 'abc', 'baseline/screen:1')
    y = y + Editor_state.line_height
    local drawing_height = Drawing_padding_height + drawing_width/2 -- default
    y = y + drawing_height
    App.screen.check(y, 'ghi', 'baseline/screen:3')
    check(Editor_state.cursor_x, 'baseline/cursor_x')
    -- after hitting the up arrow the cursor moves up by 2 lines, skipping the drawing
    edit.run_after_keychord(Editor_state, 'up')
    check_eq(Editor_state.cursor1.line, 1, 'cursor')
    end
  • replacement in text.lua at line 429
    [3.657][3.415:476]()
    State.cursor1 = {line=State.cursor1.line-1, pos=nil}
    [3.657]
    [3.208]
    State.cursor1 = {line=new_cursor_line, pos=nil}
  • edit in source_text_tests.lua at line 1026
    [2.32282]
    [3.38177]
    end
    function test_down_arrow_skips_drawing()
    -- some lines of text with a drawing intermixed
    local drawing_width = 50
    App.screen.init{width=Editor_state.left+drawing_width, height=100}
    Editor_state = edit.initialize_test_state()
    Editor_state.lines = load_array{'abc', -- height 15
    '```lines', '```', -- height 25
    'ghi'}
    Text.redraw_all(Editor_state)
    Editor_state.cursor1 = {line=1, pos=1}
    Editor_state.screen_top1 = {line=1, pos=1}
    Editor_state.screen_bottom1 = {}
    edit.draw(Editor_state)
    local y = Editor_state.top
    App.screen.check(y, 'abc', 'baseline/screen:1')
    y = y + Editor_state.line_height
    local drawing_height = Drawing_padding_height + drawing_width/2 -- default
    y = y + drawing_height
    App.screen.check(y, 'ghi', 'baseline/screen:3')
    check(Editor_state.cursor_x, 'baseline/cursor_x')
    -- after hitting the down arrow the cursor moves down by 2 lines, skipping the drawing
    edit.run_after_keychord(Editor_state, 'down')
    check_eq(Editor_state.cursor1.line, 3, 'cursor')
  • edit in source_text_tests.lua at line 1201
    [3.47509]
    [3.47509]
    function test_up_arrow_skips_drawing()
    -- some lines of text with a drawing intermixed
    local drawing_width = 50
    App.screen.init{width=Editor_state.left+drawing_width, height=100}
    Editor_state = edit.initialize_test_state()
    Editor_state.lines = load_array{'abc', -- height 15
    '```lines', '```', -- height 25
    'ghi'}
    Text.redraw_all(Editor_state)
    Editor_state.cursor1 = {line=3, pos=1}
    Editor_state.screen_top1 = {line=1, pos=1}
    Editor_state.screen_bottom1 = {}
    edit.draw(Editor_state)
    local y = Editor_state.top
    App.screen.check(y, 'abc', 'baseline/screen:1')
    y = y + Editor_state.line_height
    local drawing_height = Drawing_padding_height + drawing_width/2 -- default
    y = y + drawing_height
    App.screen.check(y, 'ghi', 'baseline/screen:3')
    check(Editor_state.cursor_x, 'baseline/cursor_x')
    -- after hitting the up arrow the cursor moves up by 2 lines, skipping the drawing
    edit.run_after_keychord(Editor_state, 'up')
    check_eq(Editor_state.cursor1.line, 1, 'cursor')
    end
  • replacement in source_text.lua at line 683
    [3.7174][3.7174:7235]()
    State.cursor1 = {line=State.cursor1.line-1, pos=nil}
    [3.7174]
    [3.7235]
    State.cursor1 = {line=new_cursor_line, pos=nil}
  • replacement in source_text.lua at line 722
    [3.8200][3.8200:8262]()
    State.cursor1 = {line=State.cursor1.line-1, posB=nil}
    [3.8200]
    [3.8262]
    State.cursor1 = {line=new_cursor_line, posB=nil}