Changes inside on.initialize are minefields. Until now, if you made a mistake when modifying on.initialize, you could end up in a situation where the app would fail irrecoverably on the next startup. You'd have to go dig up a text editor to fix it.
After this commit, errors in on.initialize wait for commands from driver.love just like any other error.
Recovering from errors during initialization is a little different than normal. I don't know how much of initialization completed successfully, so I redo all of it.
I think this should be safe; the sorts of things we want to do on startup tend to be idempotent just like the sorts of things we do within an event loop with our existing error handling.
Things are still not ideal. Initialization by definition happens only when the app starts up. When you make changes to it, you won't find out about errors until you restart the app[1], which can be much later and a big context switch. But at least you'll be able to fix it in the usual way. Slightly more seamless[2].
One glitch to note: at least on Linux, an app with an initialization error feels "sticky". I can't seem to switch focus away from it using Alt-tab. Hitting F4 on the driver also jarringly brings the client app back in focus when there was an initialization error. But the mouse does work consistently. This feels similar to the issues I find when an app goes unresponsive sometimes. The window manager really wants me to respond to the dialog that it's unresponsive.
Still, feels like an improvement.
[1] I really need to provide that driver command to restart the app! But there's no room in the menus! I really need a first-class command palette like pensieve.love has!
[2] https://lobste.rs/s/idi1wt/open_source_vs_ux
5WHW3IDOHOBXY3M3QPXNMHFFNXXD6RR5B2WL6TB5TTVNZJYCN2AQC
QRUFNFPP3EDJDYTAJGUTY6CVIGNKNTSF53YN22RRVMHXDO6MUJOQC
BQH7ANWMOV3WODWYEC2AH4QGBMJRNIO2TAHHQBYHVXYWJKDZLG6AC
GSIADI3SJOLBIXOYHZRTF7SLZLK2PH44GIAD7H2GJ3VVCVO4BIUAC
YONFBSVBBNIARWDVDBG56GDPTLC6N25TLDTCVVZZ6AHBZG42H7ZAC
T7QIIGQ6YYTTYCVHVEAZSUQ3O4LYBHGPFL4K6D5TA4BA7PND4EJQC
PJ5PQAQEEWQDDEPKP3RURCFDX7SSUIH4GZJCDZ6E6UU6G55KB7KAC
OTIBCAUJ3KDQJLVDN3A536DLZGNRYMGJLORZVR3WLCGXGO6UGO6AC
IZGDTFAM3MOM5VUG6TEWLGKEMQW7WCB46FZ44DGBXC6WRANNI6VAC
LRDM35CEK3OHXOTB7TEFJRL7P6PQWO5ZG3F2BVA7DIDFHBPJQ7KAC
JNJ4R56X3HVU4IGKZZ2IV73PALEXSYOIOAIVXZTV43BG7PEY6AOQC
3QNOKBFMKBGXBVJIRHR2444JRRMBTABHE4674NR3DT67RRM2X6GAC
36Z442IVPXHZ7D2QI26YLN3TDDEMDRQ2GKBYQAD6NUHQZVCCY4VAC
DTBFNHJDOFMUXRAFVN3NYK2IJYH75EITUIPJIS3CNP7RS6OY5LVQC
BJ5X5O4ACBBJ56LRBBSTCW6IBQP4HAEOOOPNH3SKTA4F66YTOIDAC
-- Stash current state of App for tests
App_for_tests = {}
for k,v in pairs(App) do
App_for_tests[k] = v
end
-- there's one nested table
App_for_tests.screen = {}
for k,v in pairs(App.screen) do
App_for_tests.screen[k] = v
-- Stash initial state of App (right after loading files) for tests
if App_for_tests == nil then
App_for_tests = {}
for k,v in pairs(App) do
App_for_tests[k] = v
end
-- there's one nested table
App_for_tests.screen = {}
for k,v in pairs(App.screen) do
App_for_tests.screen[k] = v
end
driver, define on.initialize with a run-time error:
```
on.initialize = function()
foo = bar+1
end
```
Hit F4.
Quit the client app and restart. App shows an error.
Edit `on.initialize` in the driver and remove the error:
```
on.initialize = function()
end
```
Hit F4. The error disappears from the app and driver.
* clone this repo to a new client app, clear its save dir, run it, run the
driver, define on.initialize with a run-time error:
```
on.initialize = function()
foo = bar+1
end
```
Hit F4.
Quit the client app and restart. App shows an error.
Hit F4 again in the driver (without fixing the error).
The client app continues to show the error.
* clone this repo to a new client app, clear its save dir, run it, run the