VsVim icon indicating copy to clipboard operation
VsVim copied to clipboard

`gj` goes to the beginning of shorter lines only in .cs files

Open 333fred opened this issue 6 years ago • 3 comments

Describe the bug Yeah, this is one of those. Given two lines in a C# source file:

class C
{
    public static void Main()
    {
        Console.WriteLine("Hello world") /* Cursor here */;
    }
}

Pressing j on the WriteLine line towards the end moves the cursor to beginning of the line, as if I had pressed j0 and not just j. This only reproduces in .cs files. Not in .vb files or .vsvimrc files as far as I can tell. It's also not a 2.8 regression: I tested with 2.7 to be sure. My guess is it's a 16.4 regression. I'm currently running 16.4.2.

To Reproduce Steps to reproduce the behavior:

  1. Create a new C# project
  2. Click on a line longer than the one below it.
  3. Hit j
  4. Cursor moves as if j0 has been hit.

Environment (please complete the following information):

Edit: I do have

nnoremap j gj
nnoremap k gk

In my vsvimrc, and this issue does seem to go away when I remove them.

  • Visual Studio version: 16.4.2
  • VsVim version: 2.8.0.0 (but also reproduces in 2.7.0.0)
  • Programming Language: C# (important!)
  • Check(Type 'x') any that are installed:
    • [ ] ReSharper
    • [ ] Visual Assist

333fred avatar Dec 23 '19 04:12 333fred

Did some quick debugging on my machine and found the following:

  1. The setting wrap must be enabled to see this behavior.
  2. The bug reproduces on all file types. Specifically tested .cs and .txt. @333fred possible that wrap is disabled in .txt files and hence why you only see the behavior in .cs?
  3. The bug is in the motion logic, not caret movement. That is if you test by executing ygj you will see the behavior outlined in the bug report in the yanked text.
  4. This will repro when the caret in the start line is longer than the destination line and the caret is inside the portion of the line that doesn't exist in the destination.

jaredpar avatar Dec 31 '19 23:12 jaredpar

@jaredpar I didn't test with txt files, just cs, vb, and (vs) vimrc.

333fred avatar Jan 01 '20 05:01 333fred

@jaredpar I'm having this issue as well, but I cannot reproduce it when running VimApp from source! I want to check if I can reproduce it from source for VsVim2022, but I can't seem to build that project.

chtenb avatar Oct 17 '23 07:10 chtenb