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.
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