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

G does not move to the last line if it is an empty line. #1852

Closed
chaitanyagurrapu opened this issue Oct 22, 2016 · 4 comments
Closed

G does not move to the last line if it is an empty line. #1852

chaitanyagurrapu opened this issue Oct 22, 2016 · 4 comments
Milestone

Comments

@chaitanyagurrapu
Copy link
Contributor

In Vim, if the last line is an empty line, pressing G will go to that line. In VsVim it doesn't do that. One possible fix is to change the 'GetLastLine' behavior in EditorUtils. I have a PR up with the change. Although, it is more of a roll back as the original code is from here https://searchcode.com/codesearch/view/9488852/# so I am sure it was originally written and later deleted by @jaredpar

Alternately, there seems to be a fix possible in VsVim itself as I came across these unit tests ...

image

Clearly there should be a way to move to the last line on a 'G' without changing editor utils. I can have a look and try to submit a PR if you could specify what would be a preferred fix.

@jaredpar jaredpar added this to the 2.6.0 milestone Jan 13, 2018
@ricksladkey
Copy link
Collaborator

Sorry to be a pain-in-the-neck, but I think that this is a regression from my point of view. The so-called empty last line is not a line at all from vim's point of view; it is a phantom line. It's just the linebreak of the last line.

All you have to do to see it is open any file in the VsVim code base because they all end in a linebreak, e.g. VsVim\Test\VimCoreTest\NormalModeIntegrationTest.cs, in vim and press G and compare it to opening the same file in VsVim and pressing G.

In vim, pressing G goes to the traditional last line, i.e. the line containing }
After #2085, pressing G in VsVim goes after the last last, to the beginning of the phantom line.

In fact, vim by default ensures that a file that ends in a linebreak continues to end in a linebreak.

By contrast, VsVim, by allowing you to move to the beginning of the phantom line, makes it very easy to accidentally omit the final linebreak. So modifying G to move it there seems wrong.

@paul2t
Copy link

paul2t commented Jan 8, 2019

I think that this issue is back with the latest version of vsvim (2.6.0.0)
When the last line is empty:
G goes to the line before the last one.
Moreover, j also stops at the line before the last.
} and ) are working fine.

@ricksladkey
Copy link
Collaborator

@paul2t The best way to diagnose this is to open the same file in VsVim and gvim and test the various commands. If you do this, you will see the G and j work the same way in Vsvim as they do in gvim. However, you are right that } and ) can move to the phantom line. If you want to open a new issue to fix } and ), I'll take a look at it.

@paul2t
Copy link

paul2t commented Jan 8, 2019

Oh ok, you are right. Sorry, I didn't read your previous comment correctly.
I understand now. in vim if the last line is empty, it is not shown. Unlike visual studio. That's why I thought this was a bug.
Thanks for your work, this is a great plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants