migrate old settings, attempt #3

[?]
Sep 19, 2022, 7:53 AM
A23MMLJHXQOVDZHJCPCCP4SIFXTB7HXJMCCDAM2I7Q7BAIXMAYBAC

Dependencies

  • [2] NFI42KGX more correct absolute path detection
  • [3] S3PNFXTB handle missing cursors in settings
  • [4] SDO4DHNU source: load cursor position from settings
  • [5] KKMFQDR4 editing source code from within the app
  • [6] AOZX2G5F source: no commandline args

Change contents

  • edit in source_file.lua at line 218
    [2.499]
    [2.499]
    end
    function dirname(path)
    local os_path_separator = package.config:sub(1,1)
    if os_path_separator == '/' then
    -- POSIX systems permit backslashes in filenames
    return path:match('.*/') or './'
    elseif os_path_separator == '\\' then
    return path:match('.*[/\\]') or './'
    else
    error('What OS is this? LÖVE reports that the path separator is "'..os_path_separator..'"')
    end
    end
    function test_dirname()
    check_eq(dirname('a/b'), 'a/', 'F - test_dirname')
    check_eq(dirname('x'), './', 'F - test_dirname/current')
    end
    function basename(path)
    local os_path_separator = package.config:sub(1,1)
    if os_path_separator == '/' then
    -- POSIX systems permit backslashes in filenames
    return string.gsub(path, ".*/(.*)", "%1")
    elseif os_path_separator == '\\' then
    return string.gsub(path, ".*[/\\](.*)", "%1")
    else
    error('What OS is this? LÖVE reports that the path separator is "'..os_path_separator..'"')
    end
  • edit in source_file.lua at line 248
    [2.503]
    function empty(h)
    for _,_ in pairs(h) do
    return false
    end
    return true
    end
  • replacement in source.lua at line 89
    [4.114][4.12:180]()
    Editor_state.screen_top1 = File_navigation.cursors[Editor_state.filename].screen_top1
    Editor_state.cursor1 = File_navigation.cursors[Editor_state.filename].cursor1
    [4.114]
    [4.167813]
    if File_navigation.cursors[Editor_state.filename] then
    Editor_state.screen_top1 = File_navigation.cursors[Editor_state.filename].screen_top1
    Editor_state.cursor1 = File_navigation.cursors[Editor_state.filename].cursor1
    else
    Editor_state.screen_top1 = {line=1, pos=1}
    Editor_state.cursor1 = {line=1, pos=1}
    end
  • edit in source.lua at line 137
    [4.169643]
    [3.12]
    Editor_state.filename = basename(Editor_state.filename) -- migrate settings that used full paths; we now support only relative paths within the app