state validation in source editor as well

[?]
Mar 17, 2023, 5:46 PM
IX5YTLSVVGQSTXUNGYK526DJ4YWIXO2JRBCOFCANBJJO3ZM2S7ZAC

Dependencies

  • [2] A23MMLJH migrate old settings, attempt #3
  • [3] KKMFQDR4 editing source code from within the app
  • [4] ZJOSQFN6 bugfix: path munging on Windows
  • [5] B4JEWKWI hide editor cursor while in file navigator
  • [6] OI4FPFIN support drawings in the source editor

Change contents

  • replacement in source_edit.lua at line 118
    [3.155350][3.19723:19757]()
    function edit.fixup_cursor(State)
    [3.155350]
    [3.19757]
    function edit.check_locs(State)
    -- if State is inconsistent (i.e. file changed by some other program),
    -- throw away all cursor state entirely
    if edit.invalid1(State, State.screen_top1)
    or edit.invalid1(State, State.cursor1)
    or not edit.cursor_on_text(State)
    or not Text.le1(State.screen_top1, State.cursor1) then
    State.screen_top1 = {line=1, pos=1}
    edit.put_cursor_on_first_text_line(State)
    end
    end
    function edit.invalid1(State, loc1)
    return loc1.line > #State.lines
    or loc1.pos > #State.lines[loc1.line].data
    end
    function edit.cursor_on_text(State)
    return State.cursor1.line <= #State.lines
    and State.lines[State.cursor1.line].mode == 'text'
    end
    function edit.put_cursor_on_first_text_line(State)
  • replacement in source_edit.lua at line 143
    [3.19828][3.19828:19857]()
    State.cursor1.line = i
    [3.19828]
    [3.19857]
    State.cursor1 = {line=i, pos=1}
  • edit in source.lua at line 90
    [2.1383]
    [3.167813]
    edit.check_locs(Editor_state)