bugfix: clear selection when clicking above or below lines

[?]
Sep 20, 2023, 8:39 PM
656FM555BRGLHJ7PTIZXD2IY5T7PGFEYSHG2T3Z7WNX6QZ5KROSAC

Dependencies

  • [2] SGMA5JLE save the list of tests in repo
  • [3] 6XCJX4DZ bugfix: inscript's bug
  • [4] 5SM6DRHK port inscript's bugfix to source editor
  • [5] 7FPELAZB ah, I see the problem
  • [6] 2L5MEZV3 experiment: new edit namespace
  • [7] G54H3YG2 get rid of all bifold text
  • [8] MRA2Y3EE idea: set recent_mouse on mouse events
  • [9] KMSL74GA support selections in the source editor
  • [10] LNUHQOGH start passing in Editor_state explicitly
  • [11] QJISOCHJ some temporary logging to catch a bug
  • [12] GNKUD23I get rid of recent_mouse
  • [13] KKMFQDR4 editing source code from within the app
  • [14] GFXWHTE6 mouse wheel support
  • [15] LF7BWEG4 group all editor globals
  • [*] LXTTOB33 extract a couple of files
  • [*] 5BMR5HRT click to the left of a line
  • [*] EKKFWP4D bugfix: couple of margin-relative computations
  • [*] H3ECRBXF bugfix: clicking on empty lines
  • [*] ORRSP7FV deduce test names on failures
  • [*] Y2ZIPXEM new test

Change contents

  • edit in text_tests.lua at line 278
    [18.434]
    [18.434]
    Editor_state.selection1 = {}
  • edit in text_tests.lua at line 298
    [19.689]
    [19.689]
    Editor_state.selection1 = {}
  • edit in text_tests.lua at line 317
    [5.7940]
    [20.354]
    Editor_state.selection1 = {}
  • edit in text_tests.lua at line 322
    [20.473]
    [21.2279]
    check_eq(Editor_state.cursor1.line, 1, 'cursor')
    -- selection remains empty
    check_nil(Editor_state.selection1.line, 'selection is empty to avoid perturbing future edits')
    end
    function test_click_below_all_lines()
    -- display one line
    App.screen.init{width=50, height=80}
    Editor_state = edit.initialize_test_state()
    Editor_state.lines = load_array{'abc'}
    Text.redraw_all(Editor_state)
    Editor_state.cursor1 = {line=1, pos=1}
    Editor_state.screen_top1 = {line=1, pos=1}
    Editor_state.screen_bottom1 = {}
    Editor_state.selection1 = {}
    -- click below first line
    edit.draw(Editor_state)
    edit.run_after_mouse_click(Editor_state, Editor_state.left+8,Editor_state.top+50, 1)
    -- cursor doesn't move
  • edit in text_tests.lua at line 342
    [21.2330]
    [22.524]
    -- selection remains empty
    check_nil(Editor_state.selection1.line, 'selection is empty to avoid perturbing future edits')
  • edit in text_tests at line 26
    [2.746]
    [2.746]
    click below final line does nothing
  • edit in source_text_tests.lua at line 278
    [5.14324]
    [5.14324]
    Editor_state.selection1 = {}
  • edit in source_text_tests.lua at line 298
    [5.15229]
    [5.15229]
    Editor_state.selection1 = {}
  • edit in source_text_tests.lua at line 317
    [5.16039]
    [5.16039]
    Editor_state.selection1 = {}
  • edit in source_text_tests.lua at line 322
    [5.16198]
    [21.25645]
    check_eq(Editor_state.cursor1.line, 1, 'cursor')
    -- selection remains empty
    check_nil(Editor_state.selection1.line, 'selection is empty to avoid perturbing future edits')
    end
    function test_click_below_all_lines()
    -- display one line
    App.screen.init{width=50, height=80}
    Editor_state = edit.initialize_test_state()
    Editor_state.lines = load_array{'abc'}
    Text.redraw_all(Editor_state)
    Editor_state.cursor1 = {line=1, pos=1}
    Editor_state.screen_top1 = {line=1, pos=1}
    Editor_state.screen_bottom1 = {}
    Editor_state.selection1 = {}
    -- click below first line
    edit.draw(Editor_state)
    edit.run_after_mouse_click(Editor_state, Editor_state.left+8,Editor_state.top+50, 1)
    -- cursor doesn't move
  • edit in source_text_tests.lua at line 342
    [21.25696]
    [5.16289]
    -- selection remains empty
    check_nil(Editor_state.selection1.line, 'selection is empty to avoid perturbing future edits')
  • replacement in source_edit.lua at line 298
    [4.5220][4.5220:5269]()
    -- still here? click is below all screen lines
    [4.5220]
    [4.5269]
    -- still here? mouse press is below all screen lines
  • edit in source_edit.lua at line 320
    [4.5700]
    [5.31211]
    if y < State.top then
    State.cursor1 = {line=State.screen_top1.line, pos=State.screen_top1.pos}
    edit.clean_up_mouse_press(State)
    return
    end
  • replacement in source_edit.lua at line 335
    [4.5901][5.31612:32056](),[5.7222][5.31612:32056](),[5.31612][5.31612:32056]()
    if State.mousepress_shift then
    if State.old_selection1.line == nil then
    State.selection1 = State.old_cursor1
    else
    State.selection1 = State.old_selection1
    end
    end
    State.old_cursor1, State.old_selection1, State.mousepress_shift = nil
    if eq(State.cursor1, State.selection1) then
    State.selection1 = {}
    end
    break
    [4.5901]
    [5.32056]
    edit.clean_up_mouse_press(State)
    return
  • edit in source_edit.lua at line 340
    [5.32086]
    [4.5902]
    -- still here? mouse release is below all screen lines
    State.cursor1.line, State.cursor1.pos = State.screen_bottom1.line, Text.pos_at_end_of_screen_line(State, State.screen_bottom1)
    edit.clean_up_mouse_press(State)
  • edit in source_edit.lua at line 345
    [4.6097]
    [5.11]
    end
    end
    function edit.clean_up_mouse_press(State)
    if State.mousepress_shift then
    if State.old_selection1.line == nil then
    State.selection1 = State.old_cursor1
    else
    State.selection1 = State.old_selection1
    end
  • edit in source_edit.lua at line 356
    [5.17]
    [5.17]
    State.old_cursor1, State.old_selection1, State.mousepress_shift = nil
    if eq(State.cursor1, State.selection1) then
    State.selection1 = {}
    end
  • replacement in edit.lua at line 294
    [3.2288][3.2288:2337]()
    -- still here? click is below all screen lines
    [3.2288]
    [3.2337]
    -- still here? mouse press is below all screen lines
  • edit in edit.lua at line 316
    [3.2768]
    [5.5479]
    if y < State.top then
    State.cursor1 = {line=State.screen_top1.line, pos=State.screen_top1.pos}
    edit.clean_up_mouse_press(State)
    return
    end
  • replacement in edit.lua at line 331
    [5.354][5.5833:5978](),[5.744][5.5833:5978](),[5.1049][5.5833:5978](),[3.2969][5.5833:5978](),[5.5833][5.5833:5978](),[5.5978][5.9343:9360](),[5.101854][5.9343:9360](),[5.9343][5.9343:9360](),[5.9360][5.5979:6033](),[5.6033][5.9402:9432](),[5.101923][5.9402:9432](),[5.9402][5.9402:9432](),[5.9432][5.6034:6202](),[5.6202][5.9564:9594](),[5.102134][5.9564:9594](),[5.9564][5.9564:9594]()
    if State.mousepress_shift then
    if State.old_selection1.line == nil then
    State.selection1 = State.old_cursor1
    else
    State.selection1 = State.old_selection1
    end
    end
    State.old_cursor1, State.old_selection1, State.mousepress_shift = nil
    if eq(State.cursor1, State.selection1) then
    State.selection1 = {}
    end
    break
    [3.2969]
    [5.9594]
    edit.clean_up_mouse_press(State)
    return
  • edit in edit.lua at line 336
    [5.9624]
    [3.2970]
    -- still here? mouse release is below all screen lines
    State.cursor1.line, State.cursor1.pos = State.screen_bottom1.line, Text.pos_at_end_of_screen_line(State, State.screen_bottom1)
    edit.clean_up_mouse_press(State)
  • edit in edit.lua at line 341
    [3.3165]
    [5.1864]
    end
    end
    function edit.clean_up_mouse_press(State)
    if State.mousepress_shift then
    if State.old_selection1.line == nil then
    State.selection1 = State.old_cursor1
    else
    State.selection1 = State.old_selection1
    end
  • edit in edit.lua at line 352
    [5.1870]
    [5.1870]
    State.old_cursor1, State.old_selection1, State.mousepress_shift = nil
    if eq(State.cursor1, State.selection1) then
    State.selection1 = {}
    end