Improve the behaviour of Home in non-vim mode#639
Merged
dzhou121 merged 2 commits intolapce:masterfrom Jun 18, 2022
Merged
Conversation
Previously, pressing <kbd>Home</kbd> would always return to the first non-indent character However, a nicer behaviour once you are at that character is to move to the start of the line instead
dzhou121
reviewed
Jun 18, 2022
lapce-data/src/document.rs
Outdated
| let line = self.buffer.line_of_offset(offset); | ||
| let new_offset = self.buffer.first_non_blank_character_on_line(line); | ||
| (new_offset, Some(ColPosition::FirstNonBlank)) | ||
| if offset == new_offset { |
Collaborator
There was a problem hiding this comment.
Maybe it should be if offset <= new_offset ?
Contributor
Author
There was a problem hiding this comment.
So, the reason for this version is that if your line is
<|> blah
and you press home, the correct behaviour is to make your cursor move to:
<|>blah
At least, that's what vscode does.
Basically, pressing home should cycle between the two states, defaulting to the first non-whitespace character.
Collaborator
There was a problem hiding this comment.
I just tested VSCode,
If the cursor is at the left of the first non-whitespace character, Home gets to the line beginning?
Contributor
Author
There was a problem hiding this comment.
Ah, great. I'll implement that version then
Collaborator
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously, pressing Home would always return to the first non-indent character
However, a nicer behaviour once you are at that character is to move to the start of the line instead.
This is consistent with the behaviour of vscode.