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 movement in wrapped lines changed from 1.10.2 to 1.11.0 #4120

Closed
jrwrigh opened this issue Oct 1, 2019 · 8 comments · Fixed by #4127
Closed

Cursor movement in wrapped lines changed from 1.10.2 to 1.11.0 #4120

jrwrigh opened this issue Oct 1, 2019 · 8 comments · Fixed by #4127

Comments

@jrwrigh
Copy link

jrwrigh commented Oct 1, 2019

Describe the bug
Using the gj and gk binding to move by wrapped line instead of the file line does not work correctly in version 1.11.0, but works fine when downgrading to 1.10.2.

Specifically, here are the issues I've experienced:

  1. sometimes it will move up (gj) by file line, but down (gk) by wrapped line. Though this behavior is inconsistent and reverses itself sometimes.
  2. when it does successfully move by wrapped line, it'll change the relative character position, sometimes moving to the last character in the wrapped line, sometimes the first, sometimes by a (seemingly) random number of characters in either direction. (Note: this is moving in a block of text where there are several wrapped lines for every file line)

To Reproduce
Go to file with lots of wrapped lines (or take a normal file and make the window really narrow) and move up and down with gj and gk.

Expected behavior
It to move by one wrapped line and maintain the same lateral character position (assuming there is a character present in that lateral character position).

Environment (please complete the following information):

  • Extension (VsCodeVim) version: 1.11.0
  • VSCode version: 1.37.1
  • OS: Manjaro 18.1

Note: Manjaro currently doesn't have vscode 1.38.x on it's stable branch. This is why I'm a version behind the latest.

@J-Fields
Copy link
Member

J-Fields commented Oct 1, 2019

Can you confirm it works with no line wrapping? We fixed gj's behavior over lines of different lengths in 1.11.0, but maybe we messed up its behavior when lines are wrapped

@jrwrigh
Copy link
Author

jrwrigh commented Oct 1, 2019

When turning word wrapping off, gj and gk do work correctly (as in they do exactly what j and k would do) in 1.11.0.

@J-Fields
Copy link
Member

J-Fields commented Oct 1, 2019

Thanks for the confirmation, and sorry for the regression. This change was made via #3890. @hetmankp would you mind taking a look when you get a chance? I'll do the same.

@jrwrigh
Copy link
Author

jrwrigh commented Oct 1, 2019

No worries. Downgrading the extension is simple enough, so it's not to difficult to work around right now.

@hetmankp
Copy link
Contributor

hetmankp commented Oct 3, 2019

Turns out fixing this is impossible because of the limitations of the VSCode API and the way VSCodeVim interacts with the editor cursors. I will submit a PR to more or less reverse the previous change with additional explanations for anyone looking into this in the future.

hetmankp added a commit to hetmankp/VSCodeVim that referenced this issue Oct 3, 2019
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.
@hetmankp
Copy link
Contributor

hetmankp commented Oct 3, 2019

Not sure why the pull request wasn't automatically reference by GitHub but the PR to revert to the previous behaviour is found at #4127

@jrwrigh
Copy link
Author

jrwrigh commented Oct 3, 2019

Looks like since this issue wasn't mentioned in the pull request itself it doesn't get referenced (even though you referenced it in the commit.

@hetmankp
Copy link
Contributor

hetmankp commented Oct 4, 2019

Looks like since this issue wasn't mentioned in the pull request itself it doesn't get referenced (even though you referenced it in the commit.

Yes, you're right . It has to be mentioned in the body of the issue description and not the title. Though oddly enough GitHub picked up the title mention from the repository where the pull request came from...

J-Fields pushed a commit that referenced this issue Oct 5, 2019
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants