-
Notifications
You must be signed in to change notification settings - Fork 281
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
Fix arrow-up when the cursor is at the end of a wrapped line in a multiple-line text #1028
Conversation
/cc @msftrncs |
I will try adding a test. |
@msftrncs Would you mind review the changes? Thanks! |
This does resolve the problem. When the cursor has been intentionally moved to the end of the wrapped line (or came from being intentionally placed at the end of a line below or a line above), pressing up arrow will take the cursor up to the end of the next full line up. On the other hand, if the cursor landed at the end of a wrapped line with a up-arrow not from the end of the line below, or down-arrow not from the end of the line above, the cursor resumes its normal place when going up or down another line (when it is able to). I checked this behavior with multiple wrapped lines in a row, with both existing history from my session and with some jibberish here-strings quickly formulated. I did find a new behavior that seemed not to exist before (I cannot repeat it with Windows PowerShell which I still have running PSReadLine 2.0.0 beta @'
hello
`@ With the cursor sitting on 'o' (not after it), pressing down and back up work as expected, but pressing down twice, then back up takes the cursor to past the 'o', as now it moves to the logical line ends. |
Good catch @msftrncs, thank you! |
Thanks all for the review! |
Fix #1020
When the cursor is at the end of a wrapped line, Up key sets the potential new cursor position to the previous physical line, and then calculates the end of the logical line rendered in that physical line, and eventually ends up in the same old cursor position.
That's why Up at the end of a warped line doesn't work.
The fix is to not depend on the physical line position when the original cursor is at the end of line, but directly search back (for Up) and search forward (for Down) for new line characters.