Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly handle :cq #269

Closed
wants to merge 1 commit into from
Closed

Properly handle :cq #269

wants to merge 1 commit into from

Conversation

bk2204
Copy link

@bk2204 bk2204 commented Dec 19, 2021

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

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.
@jacobmischka
Copy link
Contributor

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

@bk2204 bk2204 closed this Dec 19, 2021
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.

Exits successfully with :cq
2 participants