Skip to content
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

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

Closed
clemtoy opened this issue Jan 31, 2017 · 19 comments · Fixed by #21338
Closed

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

clemtoy opened this issue Jan 31, 2017 · 19 comments · Fixed by #21338
Assignees
Labels
editor-core Editor basic functionality feature-request Request for new features or functionality good first issue Issues identified as good for first-time contributors help wanted Issues identified as good community contribution opportunities
Milestone

Comments

@clemtoy
Copy link

clemtoy commented Jan 31, 2017

  • 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

@alexdima alexdima added editor-core Editor basic functionality editor labels Feb 1, 2017
@alexdima alexdima added this to the Backlog milestone Feb 1, 2017
@rebornix rebornix added the feature-request Request for new features or functionality label Feb 1, 2017
@rebornix
Copy link
Member

rebornix commented Feb 1, 2017

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.

@rebornix rebornix added good first issue Issues identified as good for first-time contributors help wanted Issues identified as good community contribution opportunities labels Feb 1, 2017
@flowmemo
Copy link

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

@clemtoy
Copy link
Author

clemtoy commented Feb 14, 2017

@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.

@flowmemo
Copy link

@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?

@misoguy
Copy link
Contributor

misoguy commented Feb 15, 2017

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?

@clemtoy
Copy link
Author

clemtoy commented Feb 21, 2017

@rebornix What is your opinion?

@rebornix
Copy link
Member

@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.

@misoguy
Copy link
Contributor

misoguy commented Feb 23, 2017

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.

@misoguy
Copy link
Contributor

misoguy commented Feb 24, 2017

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

@misoguy
Copy link
Contributor

misoguy commented Mar 14, 2017

@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!

@rebornix
Copy link
Member

rebornix commented Mar 14, 2017

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

BTW, did you have a test on #22005 (comment) as well?

@misoguy
Copy link
Contributor

misoguy commented Mar 15, 2017

@rebornix That's wierd...because I can't find any comment at https:/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 039a54d

@rebornix
Copy link
Member

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 :)

@misoguy
Copy link
Contributor

misoguy commented Mar 16, 2017

@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.

@rebornix
Copy link
Member

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

@misoguy
Copy link
Contributor

misoguy commented Mar 20, 2017

@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~

@misoguy
Copy link
Contributor

misoguy commented Mar 20, 2017

@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)

  2. 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 :)

@marcushv
Copy link

marcushv commented Mar 30, 2017

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)

alexdima added a commit to misoguy/vscode that referenced this issue May 29, 2017
@alexdima alexdima modified the milestones: May 2017, Backlog May 29, 2017
@clemtoy
Copy link
Author

clemtoy commented Jun 2, 2017

Thank you very much !

@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
editor-core Editor basic functionality feature-request Request for new features or functionality good first issue Issues identified as good for first-time contributors help wanted Issues identified as good community contribution opportunities
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants