-
Notifications
You must be signed in to change notification settings - Fork 158
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
re-enable bracketed paste on not(windows) (fixes #9944) (fixes #648) #657
re-enable bracketed paste on not(windows) (fixes #9944) (fixes #648) #657
Conversation
Codecov Report
@@ Coverage Diff @@
## main #657 +/- ##
==========================================
+ Coverage 49.21% 49.22% +0.01%
==========================================
Files 43 43
Lines 7914 7912 -2
==========================================
Hits 3895 3895
+ Misses 4019 4017 -2
|
@@ -630,9 +630,6 @@ impl Reedline { | |||
|
|||
let result = self.read_line_helper(prompt); | |||
|
|||
#[cfg(not(target_os = "windows"))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I kind of wonder if this was originally just a typo and should've really been #[cfg(target_os = "windows"))]
because bracketed paste doesn't work in windows since crossterm doesn't support it yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The author of the original issue was using Linux. Though he was using the Windows Terminal (using debian via WSL2).
Thus it might be a Windows Terminal issue? I don't think anyone tried it to reproduce it with Windows Terminal specifically. And it seems nobody was actually able to reproduce it except @theAkito himself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can try to reproduce with WezTerm on Windows. Just tell me which commits to try & any additional useful information...
I think the easiest way to test it would be to compile nushell with: [patch.crates-io]
reedline = { git = "https://github.com/LevitatingBusinessMan/reedline.git", branch = "re-enable-bracketed-paste" } And then try to reproduce the error (first in Windows Terminal like before, if that works in WezTerm). Have you seen this error only with gpg or also other commands that take input? |
What's the point of trying to reproduce it in Windows Terminal? If it's gonna happen again, it still could be due to this terminal. |
Exactly. You can first verify the bug is still present on Windows Terminal. And then you can remove variables to find the root cause. Like if it is related to the terminal by switching to another. You can also test for the bug in WezTerm first, but if that fails you'd have to test it in Windows Terminal anyway. I am curious if the bug is specific to gpg somehow. If it isn't than I think more people would experience it. If the bug does appear in gpg try using passwd. If it is specific to gpg than it must be related to pinentry. |
also related nushell/nushell#9944 |
I tested it and believe nushell/nushell#9944 is actually fixed by this PR. @amtoine is on Linux so it makes sense. |
Makes sense. Will try, when I get the time. Am following this pull request. |
Thanks, generally I'm ok with your point. I believe it will cause nushell/nushell#9218 to reappear. But we can bring nushell/nushell#9399 back, so both reedline and nushell are useful to us again. |
Done, did it. Here is what I did, so there are no misunderstandings.
There are probably tons of other programs requiring password entry in a similar fashion, but right now none come to my mind. If you can tell me an example program, I can test, I will test the password entry there. |
Tried These are the literal characters presented to me on
GPG version
|
Are we saying this PR is ready to land or is it going to create other problems? |
Thanks to @theAkito I can now confirm that this issue is specific to curses. I was able to replicate it with a password prompt written in python (with curses). import curses
def main():
# Initialize curses
stdscr = curses.initscr()
# Prompt for password
stdscr.addstr("Paste text using bracketed_paste: ")
password = ""
while True:
key = stdscr.getch()
password += chr(key)
stdscr.clear() # Clear screen
stdscr.addstr("Paste text using bracketed_paste: " + password)
if __name__ == "__main__":
main() Escape characters |
I personally think this PR should be merged, so nushell/nushell#9944 and #648 can be closed. After this is merged, I will open a new issue at nushell, covering this issue with bracketed paste and curses. |
ok @LevitatingBusinessMan let's try your solution. I'll be looking for that nushell PR. Appreciate it. |
Weird. Cannot reproduce it in Nim. ##[
Works on Nim 2.0.0
nimble install ncurses # https://github.com/walkre-niboshi/nim-ncurses
nim c -r reedline_657.nim ; rm reedline_657
]##
import pkg/ncurses
when isMainModule:
let stdscr = initscr()
stdscr.waddstr("Paste text using bracketed_paste: ")
var password = ""
while true:
var key = stdscr.wgetch()
if key == 0: break
password &= key.chr
stdscr.werase
stdscr.waddstr(cstring("Paste text using bracketed_paste: " & password.repr)) Output just shows the characters I entered, which is, I suppose, the correct behaviour. This program's Same with this Python program. No incorrect characters |
@theAkito Did you test it using reedline compiled from git? Including this merge? |
I tested with the product of yesterday's compilation, where I did reproduce it with GPG, earlier. |
I can reproduce it just fine, by having |
Well, turns out, I had a user error, when trying to reproduce. Can reproduce now. Confirmed. 👍🏻 |
Due to a supposed issue (nushell/nushell#9218) in nushell regarding commands that read standard input, a fix (nushell/nushell#9399) was proposed that temporarily disables bracketed_paste during the execution of eval_source.
Instead, this issue was moved over to reedline and a new PR was created (#598). In this version of the "fix", bracketed_paste is disabled completely after the first execution of reedline. This has led to issue #648, where multiline paste is now being disabled on non-windows environments.
This PR effectively reverts #598. This might cause nushell/nushell#9218 to reappear in nushell.
I have personally not been able to reproduce nushell/nushell#9218, modern versions of gpg use a GUI prompt for the password, or alternatively a curses window. I did try to replicate the issue using GNU readline and other prompting methods but I wasn't succesful.
If nushell/nushell#9218 is a reproducible issue, I think the best course of action is to merge nushell/nushell#9399, which supposedly fixes the issue, but on the nushell side. It seems like this issue might be specific to nushell, and thus it should be fixed in that repository. No need to affect all other reedline dependent packages with it.