Skip to content

plugins: Run deinit() on exit() of micro - #4231

Merged
JoeKar merged 2 commits into
micro-editor:masterfrom
JoeKar:feature/plugin-deinit
Sep 20, 2026
Merged

JoeKar merged 2 commits into
micro-editor:masterfrom
JoeKar:feature/plugin-deinit

Conversation

@JoeKar

@JoeKar JoeKar commented Sep 17, 2026

Copy link
Copy Markdown
Member

This came up with #4230 and allows plugins to do some finalization stuff.

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.
Comment thread cmd/micro/micro.go
@dmaluka

dmaluka commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator

The idea seems reasonable. Although I'm a bit concerned that there might be some plugins that are using deinit() for doing some stuff which they are not expecting to be done on exit...

Trying to find out what was the original use case for this deinit() callback... This callback was introduced in commit 4027081 to support the built-in linter plugin (added in the same commit), as if the linter plugin used deinit() (it didn't, and it still doesn't). Splendid.

Possibly deinit() has never been actually used by anyone, ever. https://github.com/micro-editor/micro/issues?q=deinit doesn't give any insight about any actual users either.

@achadwick

Copy link
Copy Markdown

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 deinit() as the editor exits, especially if they already init() at startup.

@dmaluka

dmaluka commented Sep 19, 2026

Copy link
Copy Markdown
Collaborator

But, if there are really no plugins out there that have one, go for it. It isn't unreasonable for plugins to receive deinit() as the editor exits, especially if they already init() at startup.

Yeah, I agree with that.

@JoeKar
JoeKar merged commit 53824a4 into micro-editor:master Sep 20, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants