-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Wrapped line is preserved even if nothing is written before executing #6826
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
Comments
I've actually noticed this before! I think it happens in other shells too. |
Interestingly, it seems to happen in zsh, and bash when invoked as |
The newline comes from this line in reader.cpp: Line 3584 in 06658cd
Checking if the cursor position onscreen is a multiple of the screen width before writing the newline would fix it. However I didn't find a way to get the actual position of the cursor, only the position of the cursor without taking the prompt into account. Inserting a char to see if the line count increases works, but it's a bit cumbersome and requires a repaint:
(this also triggers #6951) |
There's a few subtleties here:
I think we can still do this safely - we'll see if anyone spots a regression. Fixed in 4f103d7 |
This one is subtle and the title is confusing. Sorry!
Given a terminal that is 80 characters wide, if 79 characters are entered at the prompt (including the prompt itself), the caret/cursor is now in the 80th column and no wrapping is triggered. Type in one more character and the caret moves to the start of the next line in anticipation of your input. All well and good.
If at this point you choose to execute the command as-is rather than append more text, this wrapped line is preserved in the output. This will appear to be an additional line of output rather than an extra line of input (especially if you typed it out quickly and hit enter knowing you were done, i.e. didn't wait for the cursor to move to the next line after entering a character in the 80th column).
e.g. the last two commands in the screenshot below actually produced identical output, but you wouldn't be able to tell that:
I believe we explicitly move the cursor to the next line regardless of the default terminal behavior/flags, right?
The text was updated successfully, but these errors were encountered: