daa84 / neovim-gtk

gtk ui for neovim
GNU General Public License v3.0
716 stars 57 forks source link

Properly handle :cq #269

Closed bk2204 closed 2 years ago

bk2204 commented 2 years ago

When the user invokes :cq, this causes Neovim to exit unsuccessfully. This is important if the user wishes to abort a Git commit message, or in other situations where the operation is aborted when the editor exits unsuccessfully.

Let's make this work by listening to the VimLeavePre autocommand and then reading the v:exiting code, which indicates the exit status with which Neovim is exiting. Save this into the state, and then when the detach callback is called, exit with the appropriate status.

Note that we use a separate Arc/Mutex construction here because otherwise we need to borrow the state mutably, and at that point it's already borrowed and we panic. This allows us to not need to do that, and henceforth avoid the panic.

Fixes #266

jacobmischka commented 2 years ago

This project is abandoned, but I'd recommend checking out the fork by @Lyude https://github.com/Lyude/neovim-gtk