bugfix: save previous file when dropping a new one on

[?]
Jun 30, 2022, 12:58 AM
YT5P6TO64XSMCZGTT4SVNFOWUN5ECNXTWCMFXN3YCDZUNH4H3IFAC

Dependencies

  • [2] BPWFKBXT new test: dragging and dropping a file on lines.love
  • [*] CE4LZV4T drop last couple of manual tests
  • [*] OTIBCAUJ love2d scaffold
  • [*] AVTNUQYR basic test-enabled framework
  • [*] 73OCE2MC after much struggle, a brute-force undo

Change contents

  • edit in main_tests.lua at line 38
    [2.871]
    [2.871]
    end
    function test_drop_file_saves_previous()
    io.write('\ntest_drop_file_saves_previous')
    App.screen.init{width=Margin_left+300, height=300}
    -- initially editing a file called foo that hasn't been saved to filesystem yet
    Lines = load_array{'abc', 'def'}
    Filename = 'foo'
    schedule_save()
    -- now drag a new file bar from the filesystem
    App.filesystem['bar'] = 'abc\ndef\nghi\n'
    local fake_dropped_file = {
    opened = false,
    getFilename = function(self)
    return 'bar'
    end,
    open = function(self)
    self.opened = true
    end,
    lines = function(self)
    assert(self.opened)
    return App.filesystem['bar']:gmatch('[^\n]+')
    end,
    close = function(self)
    self.opened = false
    end,
    }
    App.filedropped(fake_dropped_file)
    -- filesystem now contains a file called foo
    check_eq(App.filesystem['foo'], 'abc\ndef\n', 'F - test_drop_file_saves_previous')
  • edit in main.lua at line 193
    [6.1352]
    [7.8165]
    -- first make sure to save edits on any existing file
    if Next_save then
    save_to_disk(Lines, Filename)
    end
    -- clear the slate for the new file