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

The nvim process isn't closed when goneovim exit by 'close' button #422

Closed
damanis opened this issue Nov 4, 2022 · 5 comments
Closed

The nvim process isn't closed when goneovim exit by 'close' button #422

damanis opened this issue Nov 4, 2022 · 5 comments

Comments

@damanis
Copy link

damanis commented Nov 4, 2022

OS: LInux

  • Open ~/.bashrc in goneovim: goneovim ~/.bashrc
  • Closed the goneovim windows by 'close' button of main window
  • Check nvim process: ps ax | grep nvim | grep bachrc
    Problem: the nvim process still exists.
@damanis
Copy link
Author

damanis commented Nov 4, 2022

Seems, need notify nvim process about exit.
Also, need to let user save changes (nvim provides confirm qa command).

@damanis
Copy link
Author

damanis commented Nov 4, 2022

@akiyosi
I tried this patch. It works when file saved, but goneovim window stucks if file has unsaved changes.

diff --git a/editor/editor.go b/editor/editor.go
index 8902918..9a3439e 100644
--- a/editor/editor.go
+++ b/editor/editor.go
@@ -328,6 +328,16 @@ func InitEditor(options Options, args []string) {
 	// When an application is closed with the Close button
 	e.window.ConnectCloseEvent(func(event *gui.QCloseEvent) {
 		e.putLog("The application was closed outside of Neovim's commands, such as the Close button.")
+		for _, ws := range e.workspaces {
+			ftChan := make(chan error)
+			go func() {
+				err = ws.nvim.Command("confirm qa");
+				ftChan <-err;
+			}()
+			select {
+			case <-ftChan:
+			}
+		}
 		e.cleanup()
 		e.saveSessions()
 		if runtime.GOOS == "darwin" {

@akiyosi
Copy link
Owner

akiyosi commented Nov 8, 2022

@damanis
Thanks for this report!
I was inspired by your patch and have created a patch to remedy this issue.

6754452

I tried this patch. It works when file saved, but goneovim window stucks if file has unsaved changes.

Upon investigation of the above problem, the reason for the stacks is that while nvim is waiting for user input ([Y]es or [N]o or [C]ancel), the execution of the command is not completed and goneovim is stopped in the process of select. Here, goneovim needed to send the nvim command and exit the function without waiting for it to be processed and ignore the QCloseEvent event.

@damanis
Copy link
Author

damanis commented Nov 8, 2022

@akiyosi
Thank for explanation! Interesting subtleties.

@akiyosi
Copy link
Owner

akiyosi commented Nov 8, 2022

I have merged the patch and will close it.

@akiyosi akiyosi closed this as completed Nov 8, 2022
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

No branches or pull requests

2 participants