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

RunTermEmulator function doesn't seem to respect the "wait" flag #3243

Open
dakennedyd opened this issue Apr 10, 2024 · 1 comment
Open

RunTermEmulator function doesn't seem to respect the "wait" flag #3243

dakennedyd opened this issue Apr 10, 2024 · 1 comment

Comments

@dakennedyd
Copy link

When using the fzf plugin to open a file the plugin displays an annoying "Press enter to close" message before closing the internal terminal. The fzf plugin uses the "RunTermEmulator" function with the "wait" flag set to "false" which I assume it should make it close the internal terminal immediately but instead displays a message that says "Press enter to close" before closing.

Specifications

Version: 2.0.14-dev.131
Commit hash: acb0d76
Compiled on April 10, 2024
OS: Ubuntu 22.04
Terminal: xterm

@dmaluka
Copy link
Collaborator

dmaluka commented Apr 11, 2024

I can reproduce this. From micro's code I see that the Press enter to close message actually indicates that an error occurred. So this message seems misleading, and moreover, it doesn't tell us which error occurred.

I've instrumented the code so it says which error is it:

diff --git a/internal/shell/terminal.go b/internal/shell/terminal.go
index 6fb1ce7f..5712efbd 100644
--- a/internal/shell/terminal.go
+++ b/internal/shell/terminal.go
@@ -2,6 +2,7 @@ package shell
 
 import (
 	"bytes"
+	"fmt"
 	"os/exec"
 	"strconv"
 
@@ -97,7 +98,7 @@ func (t *Terminal) Start(execCmd []string, getOutput bool, wait bool, callback f
 		for {
 			err := Term.Parse()
 			if err != nil {
-				Term.Write([]byte("Press enter to close"))
+				Term.Write([]byte(fmt.Sprintf("Press enter to close: %v", err)))
 				screen.Redraw()
 				break
 			}

and I can see the error is:

Press enter to close: read /dev/ptmx: input/output error                                                                                                                                                           

RunTermEmulator() uses the https://github.com/zyedidia/terminal library, which opens /dev/ptmx using the https://github.com/creack/pty library, and reads characters from it. Apparently, when finishing running the fzf job, reading from /dev/ptmx fails with EIO for some reason.

We can try to debug it further.

Quick googling: https://www.google.com/search?q=%2Fdev%2Fptmx+eio

finds some possibly useful links:

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