Conversation
The screen is usually closed with `exit()`. This was overseen in commit e15bb88 (micro-editor#3273).
This allows plugins to do some cleanup short before micro is exited.
| defer func() { | ||
| if err := recover(); err != nil { | ||
| if screen.Screen != nil { | ||
| screen.Screen.Fini() | ||
| } | ||
| if e, ok := err.(*lua.ApiError); ok { | ||
| fmt.Println("Lua API error:", e) | ||
| } else { | ||
| fmt.Println("Micro encountered an error:", errors.Wrap(err, 2).ErrorStack(), "\nIf you can reproduce this error, please report it at https://github.com/micro-editor/micro/issues") | ||
| } | ||
| // immediately backup all buffers with unsaved changes | ||
| for _, b := range buffer.OpenBuffers { | ||
| if b.Modified() { | ||
| b.Backup() | ||
| } | ||
| } | ||
| exit(1) | ||
| } | ||
| }() |
There was a problem hiding this comment.
I'm not sure what you mean here. This recover() is for catching panics when micro crashes, right? How else would we catch them?
|
The idea seems reasonable. Although I'm a bit concerned that there might be some plugins that are using Trying to find out what was the original use case for this Possibly |
|
If current behaviour needs to be maintained, then a new at-exit cleanup hook plus documentation of exactly what fires when would seem appropriate. But, if there are really no plugins out there that have one, go for it. It isn't unreasonable for plugins to receive |
This came up with #4230 and allows plugins to do some finalization stuff.