Vscode: Cursor does not go to the end of line when pressing "End" with word wrap enabled

Created on 31 Jan 2017  路  19Comments  路  Source: microsoft/vscode

  • VSCode Version: 1.8.1
  • OS Version: Windows 10

Steps to Reproduce:

  1. Enable the word wrapping: "editor.wordWrap": true
  2. Write a line long enough so that it covers multiple lines
  3. Put the cursor at the beginning of the line
  4. Press the End button

The cursor does not go to the EOL character.

Example here

editor editor-core feature-request good first issue help wanted

Most helpful comment

@clemtoy @misoguy thanks for your continuous input on this. I can see reasons that why going to the start/end of both line and screen line is necessary. So instead of raising other users' concern, I prefer the second proposal: double press Home/End.

All 19 comments

We have defined a bunch of target positions for cursorMove command as below

export const CursorMovePosition = {
    Left: 'left',
    Right: 'right',
    Up: 'up',
    Down: 'down',

    WrappedLineStart: 'wrappedLineStart',
    WrappedLineFirstNonWhitespaceCharacter: 'wrappedLineFirstNonWhitespaceCharacter',
    WrappedLineColumnCenter: 'wrappedLineColumnCenter',
    WrappedLineEnd: 'wrappedLineEnd',
    WrappedLineLastNonWhitespaceCharacter: 'wrappedLineLastNonWhitespaceCharacter',

    ViewPortTop: 'viewPortTop',
    ViewPortCenter: 'viewPortCenter',
    ViewPortBottom: 'viewPortBottom',

    ViewPortIfOutside: 'viewPortIfOutside'
};

Apparently we should add lineEnd and lineStart as well. A good contribution candidate for beginners.

It seems like #15121 reported a similar issue.
So, what is the expected behavior of 'Home' and 'End' with word-wrap?

@flowmemo
At least:

  • The cursor should go to the column 0 when 'Home' is pressed, instead of the start of the wrapped line.
  • The cursor should go to the EOL character when 'End' is pressed, instead of the end of the wrapped line.

Better (as Sublime Text does):

  • 'Home': the cursor goes to the start of the wrapped line at first press and to the column 0 at the second press
  • 'End': the cursor goes to the end of the wrapped line at first press end to the EOL character at the second press.

@clemtoy
It seems like different editors have their own way to deal with this situation.
I just tested this behavior in Visual Studio 2015 Community, and the result is same as in VSCode.

What is the opinion from VSCode team?

I am currently looking at this issue and trying to change the behavior of the end button.
However, I think it is important to understand the opinion from the VSCode team as @flowmemo has mentioned. Is the opinion from the VSCode team equal with what @clemtoy suggests?

@rebornix What is your opinion?

@clemtoy @misoguy thanks for your continuous input on this. I can see reasons that why going to the start/end of both line and screen line is necessary. So instead of raising other users' concern, I prefer the second proposal: double press Home/End.

Understood. I'll try to change the home/end button behaviors to clemtoy's second proposal which is stated as below.

  • 'Home': the cursor goes to the start of the wrapped line at first press and to the column 0 at the second press
  • 'End': the cursor goes to the end of the wrapped line at first press end to the EOL character at the second press.

@rebornix @clemtoy I have roughly implemented the changes to home/end button behaviors. I'm open to any kind of feedbacks!

@rebornix It's been a while since this code has been implemented and added to the PR #21338. It'd be nice to get some kind of feedback when you get the chance :) Thanks!

@misoguy I left comments there but seems you didn't see it :) https://github.com/Microsoft/vscode/pull/21338/files#r103243328

BTW, did you have a test on https://github.com/Microsoft/vscode/pull/22005#discussion_r105822604 as well?

@rebornix That's wierd...because I can't find any comment at https://github.com/Microsoft/vscode/pull/21338/files#r103243328
Could you check it one more time and make sure that your review has been submitted?
Regarding the test, do you mean the test code for editorStacksModel? If so, it is implemented as commit https://github.com/Microsoft/vscode/pull/22005/commits/039a54dd1e0dc3295a3e576d5bfc041fe156733e

screen shot 2017-03-15 at 10 39 37 am

It's about invokeAll, we need to support multiple cursors :)

screen shot 2017-03-15 at 10 40 43 am

See above screenshot :)

@rebornix Thanks for the comments! I'll see what I can do about them.
For the comment on navigating between view parts, that was a minor bug in the code and I had them fixed before being merged :) It should be consistent now.
BTW, I think it's best that you submit the reviews by clicking the Finish your review button seen on the screenshot :) So that I can see them on github and reply to the comments directly.

Sorry for making you wait for so long @misoguy now I finally know the difference between A Single Comment and Start a Review :(

@rebornix No problem~ I was working on another issue and didn't really have the time to take a second look at it anyways :) I'll try get on the comments for #21338 this week~

@clemtoy @rebornix @flowmemo After implementing the changes to the behavior of Home and End button commands, it seems to me that there are some type of different situations that should be clarified.

  1. Currently when you press Home at the first non whitespace column of a line which has indentation, it goes to the beginning of a line(column 0).
    Should this behavior be kept?
    (If it should be kept situation 2, which is the multi cursor mode will look more complex)
  1. multi cursor mode.
    Home command

    1. multi cursor in different file lines with different indentation.

      Should all the cursors go to the first non whitespace?

    2. multi cursor in different wrapped lines of a file line.

      Should all the cursors go to the first non whitespace of the file line or the wrapped line?

End command also has the same issue just vice versa.

I'm not sure if this explanation is enough to understand...Please comment for further explanation :)

Sublime Text on my macOS works as follows with wrapped lines:

  • cmd+right -> end of wrapped line

    • cmd+right x2 -> end of line

  • cmd+left -> first character of wrapped line

    • cmd+right x2 -> first character of line

    • cmd+right x3 -> column 0

  • ctrl+E -> end of line
  • ctrl+A -> column 0

I would like to be able to set up my keybindings so that I can use it the same way.
Note: ctrl+E/A are basically system wide on macOS, except for some programs (such as VSCode)

Thank you very much !

Was this page helpful?
0 / 5 - 0 ratings