-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Fix gj/gk so it maintains cursor position #3890
Conversation
64cb04b
to
e14d23d
Compare
Can you add tests? |
Done. |
00620d8
to
30ced67
Compare
30ced67
to
53f713a
Compare
Is something blocking this PR? I'd really like to see to get this merged :) |
|
||
newTest({ | ||
title: "Can handle 'gj'", | ||
start: ['blah', 'duh', '|dur', 'hur'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tests don't seem like they exhibit the bug in #1323 (since the cursor is at the front of the line each time). Am I wrong? If not, we should have some regression tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM other than a bit more test coverage
The previous fix (commit e14d23d) was somewhat naive as it conflated what should have been entirely separate classes. One set for moving the cursor up and down, and the other for moving it up and down while maintaining cursors position in wrapped lines. This conflation would probably be fine except that the former set of classes was in turn being used by the MoveUpFoldFix/MoveDownFoldFix classes. Digging through the commit history, the original confusion might have been introduced by commit 5a9f2f0. We now correctly separate Move(Up|Down)ByScreenLine classes from the Move(Up|Down)ByScreenLineMaintainDesiredColumn classes.
I’m not sure if there is a better mechanism but as a maintainer it’s hard to figure out when a PR is ready for another round of reviews. After you’ve addressed all the comments, let us know so we can take another look. |
Travis tests have failedHey @hetmankp, Node.js: 8if [[ $(git diff-index HEAD -- *.js *.ts *.md) ]]; then git diff; echo "Prettier Failed. Run `gulp forceprettier` and commit changes to resolve."; exit 1; fi
npm test
TravisBuddy Request Identifier: 797859a0-e01b-11e9-a161-570cf9dcad8d |
3cd22f7
to
bcd5471
Compare
Yes, I had wanted to add those tests a while ago but then realised visual mode behaviour was completely broken with the existing code and abandoned that effort at the time. I've reworked the original fix with better dependency hygiene, fixed visual mode behaviour so it behaves like VIM and added the requested tests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
This more or less reverts the functionality introduced by commit 4b2e079 and raised in issue VSCodeVim#3890. Unfortunately it is not currently possible to fully implement display line movements over wrapped lines that will always preserve cursor position. One of two things is necessary to change this, either the VSCode API needs to be extended to return information about wrapped lines (but this was rejected in issue microsoft/vscode#23045). Alternatively VSCodeVim would need to reïimplement all motions using vscode.commands.executeCommand() commands rather than manipulating vscode.window.activeTextEditor.selections directly, as the former preserves column position while the latter does not. However it's not clear to me if all VIM beahviour could be reïmplemented this way without first trying this out and sounds like a bit of a ground up rewrite. It seems for now we're stuck with gj/gk not preserving column position when jumping across short lines.
Closes #4120 This more or less reverts the functionality introduced by commit 4b2e079 and raised in issue #3890. Unfortunately it is not currently possible to fully implement display line movements over wrapped lines that will always preserve cursor position. One of two things is necessary to change this, either the VSCode API needs to be extended to return information about wrapped lines (but this was rejected in issue microsoft/vscode#23045). Alternatively VSCodeVim would need to reïimplement all motions using vscode.commands.executeCommand() commands rather than manipulating vscode.window.activeTextEditor.selections directly, as the former preserves column position while the latter does not. However it's not clear to me if all VIM beahviour could be reïmplemented this way without first trying this out and sounds like a bit of a ground up rewrite. It seems for now we're stuck with gj/gk not preserving column position when jumping across short lines. Add gj/gk tests for future behaviour These tests had been previously removed as supporting this behaviour is not yet possible due to technical reasons, however they do represent correct VIM behaviour so we keep them until implementation becomes architecturally possible.
This fixes the gj & gk motion commands so that they maintain column position when jumping across short lines. This fixes issue #1323 .