simplify some code now that lines contains no derived data

akkartik
Jul 8, 2024, 7:23 AM
4Z4XY6TK3DU775XME2V2FVDN7O3D3W6DO6N4OGLGVIL6M6RPCKPQC

Dependencies

  • [2] GGWAHCLE minor cleanup and a todo for later
  • [3] G3DLS5OU audit all asserts
  • [4] 73OCE2MC after much struggle, a brute-force undo
  • [5] MTJEVRJR add state arg to a few functions
  • [6] IFTYOERM line.y -> line_cache.starty in a few more places
  • [7] FUOURDEY clean up some final bifold code
  • [8] AYG2PQCG fix a couple of asserts missed in the recent audit
  • [9] KKMFQDR4 editing source code from within the app
  • [10] OI4FPFIN support drawings in the source editor
  • [11] VJ77YABH more efficient undo/redo
  • [12] LF7BWEG4 group all editor globals

Change contents

  • edit in undo.lua at line 60
    [4.1497][4.1497:1559]()
    -- deep copy lines without cached stuff like text fragments
  • replacement in undo.lua at line 61
    [4.269][4.985:1017](),[4.295][4.1592:1624](),[4.1017][4.1592:1624](),[4.1102][4.1592:1624](),[4.1592][4.1592:1624](),[4.1624][2.1:115](),[2.115][4.1687:1726](),[4.1687][4.1687:1726](),[4.1726][2.116:248](),[4.239][4.2236:2245](),[2.248][4.2236:2245](),[4.2236][4.2236:2245](),[4.2268][3.139:203](),[3.203][4.2288:2296](),[4.2288][4.2288:2296]()
    local line = State.lines[i]
    if line.mode == 'text' then
    table.insert(event.lines, {mode='text', data=line.data}) -- I've forgotten: should we deepcopy(line.data)?
    elseif line.mode == 'drawing' then
    table.insert(event.lines, {mode='drawing', h=line.h, points=deepcopy(line.points), shapes=deepcopy(line.shapes), pending={}})
    else
    assert(false, ('unknown line mode %s'):format(line.mode))
    end
    [4.269]
    [4.2296]
    table.insert(event.lines, deepcopy(State.lines[i]))
  • edit in source_undo.lua at line 60
    [4.1905][4.1905:1967]()
    -- deep copy lines without cached stuff like text fragments
  • replacement in source_undo.lua at line 61
    [4.1982][4.1982:2014](),[4.2014][4.1558:1590](),[4.1590][2.253:367](),[4.68][4.1671:1710](),[2.367][4.1671:1710](),[4.1671][4.1671:1710](),[4.1710][2.368:500](),[2.500][4.2200:2209](),[4.2200][4.2200:2209](),[4.2209][3.2457:2521](),[3.2521][4.2252:2260](),[4.2252][4.2252:2260]()
    local line = State.lines[i]
    if line.mode == 'text' then
    table.insert(event.lines, {mode='text', data=line.data}) -- I've forgotten: should we deepcopy(line.data)?
    elseif line.mode == 'drawing' then
    table.insert(event.lines, {mode='drawing', h=line.h, points=deepcopy(line.points), shapes=deepcopy(line.shapes), pending={}})
    else
    assert(false, ('unknown line mode %s'):format(line.mode))
    end
    [4.1982]
    [4.2080]
    table.insert(event.lines, deepcopy(State.lines[i]))