-
-
Notifications
You must be signed in to change notification settings - Fork 764
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
Command prompt not cleared after each command ran #499
Comments
I see something like the following with zsh and bash (output from the previous command and prompt clean and ready for next input):
|
Note: This is from master. |
I see the asciinema now. |
I built
But it also happens with the default readline too. |
This is the built-in prompt (not the readline one). In picker mode this is used. You can compile My readline version is 7.0-3. I am not seeing this issue on kitty (tested latest release available) as well. |
I compiled with readline 8.0 now. And still I don't see the issue. Probably the problem is not with libreadline/nnn as they don't handle printing to the terminal and moving the pointer forward to the end of the input. @KlzXS any ideas? |
I can't reproduce this. Is this a mac specific bug? |
@KlzXS looks like that. @novadev94 can you try with stock readline? Also, just to double check, you are on master, right? |
@jarun I did a |
Instead of hitting |
Actually looking at the asciicinema, it looks like we should flush stdout aswell.. |
Can someone confirm if the following patch works? diff --git a/src/nnn.c b/src/nnn.c
index 8266882..a183637 100644
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -1713,6 +1713,7 @@ static int spawn(char *file, char *arg1, char *arg2, const char *dir, uchar flag
while (getchar() != '\n');
}
+ fflush(stdout);
refresh();
}
|
I don't think flushing is the solution to the problem, but it should at least fix them not seeing the prompt... |
Please try the following patch: diff --git a/src/nnn.c b/src/nnn.c
index 8266882..c806446 100644
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -1711,8 +1711,8 @@ static int spawn(char *file, char *arg1, char *arg2, const char *dir, uchar flag
if (flag & F_CONFIRM) {
printf("%s", messages[MSG_CONTINUE]);
while (getchar() != '\n');
+ fflush(stdout);
}
-
refresh();
}
|
@jarun Putting diff --git a/src/nnn.c b/src/nnn.c
index 942d950..2343784 100644
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -1710,6 +1710,7 @@ static int spawn(char *file, char *arg1, char *arg2, const char *dir, uchar flag
if (flag & F_NORMAL) {
if (flag & F_CONFIRM) {
printf("%s", messages[MSG_CONTINUE]);
+ fflush(stdout);
while (getchar() != '\n');
} |
Yes, that is correct. I'd say the place where you placed And yes, anything you type until you hit If you can verify that Otherwise I have a solution in place for |
I think he intends to confirm that the fflush() in between works as intended. I would push the change as common for all platforms. Shouldn't harm. |
@novadev94 and @vuduyhung94 please confirm the patch with and without readline ( |
fflush doesn't solve the issue before of after getchar loop, with or without readline, in a pty or tty, on my end on a linux. You can reproduce the issue by pressing |
@lawnowner how about typing additional chars at the prompt before pressing Enter? Does it work in that case too? |
Anything typed during command execution is buffered and output at the end of execution, before the continue message, as I think it should; normally we don't press keys hysterically while the command is executing. With a newline after the continue message, the next prompt line is clear, and the continue message is displayed before it. |
My case is:
|
@novadev94 looks like @lawnowner has found the actual issue. |
What's the status line? The message? |
No, the nnn status line showing the file count, size, etc. It corrupts the |
@jarun Commit da8b257 has a weird behavior on tty for me (Mac), it still works ok on pty.
Putting the |
Combining both the |
@lawnowner can you confirm everything works with the suggestion in #499 (comment)? |
That's what I meant by "fflush doesn't solve the issue..."; both |
The thing with flush was only meant to enforce printing the What is going on is that our There are many methods for solving this, some of the quick and dirty hacks are:
A proper solution would Sorry I've spent too much time on this problem, I must go on with my life. Good night. |
in case anyone is dealing with this until my next session: |
Change the prompt string with |
@lawnowner do we still need the |
@jarun No. |
This should be gone for good now. Note: I made a force push to keep the commit history clean. |
Thank you guys for all your time! For the record, as 0xACE did with the great explanation above,
So to be precise, there were actually 2 problems at first
After the latest fix (91bd84c), it behaves exactly the same as mentioned here: #499 (comment) -- (1) fixed but not (2). Just want to point it out since saying |
There has been some miscommunication: Problem 1. Problem 2. I don't have the time to deal with this right now. I looked at the code and it seemed fine, though there is still one place where |
The one without ``n` is the in-built prompt shown in status bar. We do not switch out of ncurses mode for this. I'll add the fflush(). |
Done! Whoever talks about this next raises a PR. |
@novadev94 we need a help from you. None of us is on macOS, Can you please add some compilation steps related to Homebrew for macOS in the Wiki? Something like the Pi or Android steps in this page: https://github.com/jarun/nnn/wiki/Developer-guides#compile-for-pi Things users would be interested in:
Please add examples of the commands. The wiki is publicly editable BTW. |
@jarun I tried installing from source with a fresh macOS 10.13. And it worked fine with stock As with "Get master and compile on Homebrew", the
I'm happy to help but I'm not sure what should I write about here :D. Of course it's possible to install a custom version of |
What if someone wants to use make options: https://github.com/jarun/nnn/wiki/Developer-guides#make-options |
@jarun Just tried all the options, only
|
Thank you! |
And also on macOS gcc man page: http://mirror.informatimago.com/next/developer.apple.com/documentation/DeveloperTools/gcc-4.0.1/gcc/Link-Options.html
I left a note in the wiki page. |
Thanks again! |
Guys, can you please confirm this issue is not re-introduced with commit 29baa7c? Don't want to break the next release. |
Environment details (Put
x
in the checkbox along with the information)[x] Operating System: macOS Mojave 10.14.6
[x] Desktop Environment: -
[x] Terminal Emulator: Terminal.app, iTerm, Kitty (all 3)
[x] Shell: bash, zsh, fish (all 3, changed via
chsh -s
)[x] Custom desktop opener (if applicable): -
[x] Issue exists on
nnn
master: -Exact steps to reproduce the issue
nnn
]
to go to command promptecho 1
andEnter
twice]
to go to command prompt againer' to continue
https://asciinema.org/a/w3S0QPbey7oekD7QD2s73Kxko
The text was updated successfully, but these errors were encountered: