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
When using the directional keys to navigate, two cursor column positions should be used: an absolute position and a display position. The display position is always the same as the absolute position, unless the line does not have enough characters, in which case the display position is the last available position on that line.
Using up or down should move the cursor to the same position on the line immediately above or below respectively. If the line does not have enough characters to accomodate the cursor at that position, it should be displayed at the last available position instead, but the stored absolute position should not change. If the cursor is then moved again using up or down then the cursor should attempt to return to the stored absolute position, and fallback to the last available position as before. The up and down keys should never change the absolute position of the cursor, except when used on the first or last line respectively, when the absolute position is changed to the first or last available position on the line respectively.
Using left or right should move the cursor left or right one character, unless at the start or end of the line respectively, in which case the cursor should wrap around the the next available line. If the cursor's absolute position is different to its display position when left or right are used, the absolute position should then be updated to match the display position.
## What is the goal of this PR?
We store cursor positions when changing lines as described in
#748. This is standard
behaviour in other IDEs, such as IntelliJ IDEA and VSCode.
## What are the changes implemented in this PR?
We store an additional piece of data in `Cursor`, `lastCol`. This
remembers the last position of the column, which we only forget upon the
creation of a new cursor by a method other than moving up or down a
line.
## Additional info
Closes#748
Description
When using the directional keys to navigate, two cursor column positions should be used: an absolute position and a display position. The display position is always the same as the absolute position, unless the line does not have enough characters, in which case the display position is the last available position on that line.
Using
up
ordown
should move the cursor to the same position on the line immediately above or below respectively. If the line does not have enough characters to accomodate the cursor at that position, it should be displayed at the last available position instead, but the stored absolute position should not change. If the cursor is then moved again usingup
ordown
then the cursor should attempt to return to the stored absolute position, and fallback to the last available position as before. Theup
anddown
keys should never change the absolute position of the cursor, except when used on the first or last line respectively, when the absolute position is changed to the first or last available position on the line respectively.Using
left
orright
should move the cursor left or right one character, unless at the start or end of the line respectively, in which case the cursor should wrap around the the next available line. If the cursor's absolute position is different to its display position whenleft
orright
are used, the absolute position should then be updated to match the display position.Environment
Reproducible Steps
Scenario 1:
left
to move the cursor one position to the left.down
to move the cursor to the second (10 char) line.down
to move the cursor to the third (30 char) line.Scenario 2:
left
to move the cursor one position to the left.down
to move the cursor to the second (10 char) line.left
to move the cursor one position to the left.down
to move the cursor to the third (30 char) line.Expected Output
Scenario 1:
Scenario 2:
Actual Output
Scenario 1:
Scenario 2:
The text was updated successfully, but these errors were encountered: