You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
HOME on line 2 sends cursor to line 1 if line 1 is blank regardless of char position of cursor on line 2 #1109
PSReadline 2.0.0-beta5
Terminal must be capable of triggering InsertLineAbove or AddLine or InsertLineBelow keybindings.
Steps to reproduce
At a new clean prompt utilize a sequence such to insert 1 blank line. On the second line, enter some text, a command, or what not. From there, press HOME.
The cursor moves from the end of the text, to the start of the first (and empty) line.
I expected it to go to the beginning of the line the cursor was on.
This only happens when the first line is blank and HOME is pressed when the cursor is anywhere on the second line.
Note: My keybindings are the standard for Windows environments, CTRL-ENTER is bound to InsertLineAbove, and CTRL-J works for inserting \n directly as well.
When I attempt to fix this, I cause a VI mode test to fail,
A total of 1 test files matched the specified pattern.
[xUnit.net 00:00:06.27] Test.en_US_Windows.DeadKeyShouldBeIgnored [SKIP]
! Test.en_US_Windows.DeadKeyShouldBeIgnored [1ms]
X Test.en_US_Windows.ViMoveToFirstLogicalLineThenJumpToLastLogicalLine [24ms]
Error Message:
System.Exception :
---- Assert.Equal() Failure
Expected: 0
Actual: 3
I am not familiar with VI, Maxime Labelle (@springcomp), I might need some help understanding what the test expected and why changing the way GetBeginningOfLinePos() finds the beginning of the line would have any effect here.
changed the title [-]HOME on line 2 sends cursor to line 1 if line 1 is blank regardless of char position of cursor on line 1[/-][+]HOME on line 2 sends cursor to line 1 if line 1 is blank regardless of char position of cursor on line 2[/+]on Oct 20, 2019
Carl Morris (@msftrncs) I think I can reproduce your problem, but I would like to make sure about the sequence you use to create an empty first line in VI mode.
The way I see it, Ctrl+Enter creates an empty line but the _buffer does not contain the corresponding \n character. Thus, there is a mismatch between the _buffer and what is displayed on the screen.
To make it clearer, typing Ctrl+Enter displays the following prompt:
PS>
>>>
But the buffer is still an empty string at this stage (which seems wrong). The reason for this is that there is no binding for the Ctrl+Enter combination, even though the ProcessOneKey() method does not find a handler and tries to insert the key with SelfInsert(). At this stage, the key has a KeyChar property set to \0 instead of \n.
I think that is the origin of the issue you are seeing.
Now to answer your question, I agree with you that it has nothing to do with the way the GetBeginningOfLinePos() method has been changed. To reiterate, at this point, the internal test made by LineIsMultiline() returns false because, in effect, the buffer does not contain an expected \n but instead contain a \0.
Maxime Labelle (@springcomp), when I was debugging the initial find, the buffer did contain \n, and its length was set to 1, and 'current' was set to 1 as well. I will edit the issue though, to be clear, that my keybindings are the standard for Windows environments, CTRL-ENTER is bound to InsertLineAbove, and CTRL-J works for inserting \n directly as well. I'll try to spend some more time to make sure of what I saw in the state of the buffer, and possibly post a PR so the change I was trying to make can be evaluated.
I had not noticed when I copied the change between files that there was some minor differences, so I created the failure, and the test caught it. Corrected and its no longer failing the test.
Activity
msftrncs commentedon Oct 20, 2019
When I attempt to fix this, I cause a VI mode test to fail,
I am not familiar with VI, Maxime Labelle (@springcomp), I might need some help understanding what the test expected and why changing the way
GetBeginningOfLinePos()finds the beginning of the line would have any effect here.[-]HOME on line 2 sends cursor to line 1 if line 1 is blank regardless of char position of cursor on line 1[/-][+]HOME on line 2 sends cursor to line 1 if line 1 is blank regardless of char position of cursor on line 2[/+]springcomp commentedon Oct 21, 2019
Carl Morris (@msftrncs) I think I can reproduce your problem, but I would like to make sure about the sequence you use to create an empty first line in VI mode.
The way I see it, Ctrl+Enter creates an empty line but the
_bufferdoes not contain the corresponding\ncharacter. Thus, there is a mismatch between the_bufferand what is displayed on the screen.To make it clearer, typing Ctrl+Enter displays the following prompt:
But the buffer is still an empty string at this stage (which seems wrong). The reason for this is that there is no binding for the Ctrl+Enter combination, even though the
ProcessOneKey()method does not find a handler and tries to insert the key withSelfInsert(). At this stage, the key has aKeyCharproperty set to\0instead of\n.I think that is the origin of the issue you are seeing.
Now to answer your question, I agree with you that it has nothing to do with the way the
GetBeginningOfLinePos()method has been changed. To reiterate, at this point, the internal test made byLineIsMultiline()returnsfalsebecause, in effect, the buffer does not contain an expected\nbut instead contain a\0.msftrncs commentedon Oct 21, 2019
Maxime Labelle (@springcomp), when I was debugging the initial find, the buffer did contain
\n, and its length was set to 1, and 'current' was set to 1 as well. I will edit the issue though, to be clear, that my keybindings are the standard for Windows environments, CTRL-ENTER is bound to InsertLineAbove, and CTRL-J works for inserting\ndirectly as well. I'll try to spend some more time to make sure of what I saw in the state of the buffer, and possibly post a PR so the change I was trying to make can be evaluated.msftrncs commentedon Oct 22, 2019
I had not noticed when I copied the change between files that there was some minor differences, so I created the failure, and the test caught it. Corrected and its no longer failing the test.
Correct skipping of checking first character in buffer for new lines.
Correct skipping of checking first character in buffer for new lines.
Correct skipping of checking first character in buffer for new lines.