bugfix: save previous file when dropping a new one on
[?]
Jun 30, 2022, 12:58 AM
YT5P6TO64XSMCZGTT4SVNFOWUN5ECNXTWCMFXN3YCDZUNH4H3IFACDependencies
- [2]
BPWFKBXTnew test: dragging and dropping a file on lines.love - [*]
CE4LZV4Tdrop last couple of manual tests - [*]
OTIBCAUJlove2d scaffold - [*]
AVTNUQYRbasic test-enabled framework - [*]
73OCE2MCafter much struggle, a brute-force undo
Change contents
- edit in main_tests.lua at line 38
endfunction 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 yetLines = load_array{'abc', 'def'}Filename = 'foo'schedule_save()-- now drag a new file bar from the filesystemApp.filesystem['bar'] = 'abc\ndef\nghi\n'local fake_dropped_file = {opened = false,getFilename = function(self)return 'bar'end,open = function(self)self.opened = trueend,lines = function(self)assert(self.opened)return App.filesystem['bar']:gmatch('[^\n]+')end,close = function(self)self.opened = falseend,}App.filedropped(fake_dropped_file)-- filesystem now contains a file called foocheck_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 fileif Next_save thensave_to_disk(Lines, Filename)end-- clear the slate for the new file