Vim icon indicating copy to clipboard operation
Vim copied to clipboard

Ctrl-D and Ctrl-U do not update cursor correctly

Open tiehuis opened this issue 9 years ago β€’ 43 comments

  • Click thumbs-up πŸ‘ on this issue if you want it!
  • Click confused πŸ˜• on this issue if not having it makes VSCodeVim unusable.

The VSCodeVim team prioritizes issues based on reaction count.


What did you do?

Use Ctrl-D and Ctrl-U as movement keys. Also affects Ctrl-f and Ctrl-b.

What did you expect to happen?

The cursor should retain its relative position on the screen (disregard the edge of file case) during Ctrl-D and Ctrl-U movement.

What happened instead?

The cursor position is not updated within the file and drops off the visible portion of the screen. On the next successive movement there appears to be some check for an out of bounds cursor which places it to the bottom of the screen regardless of its initial position.

This makes movement with these keys unusable.

Technical details:

Pretty certain this a regression since VSCode 1.9 which did not have this problem. Doesn't appear to be any recent issues on VSCode itself relating to movement right now so not sure who the cause of this is.

  • VSCode Version: 1.10
  • VsCodeVim Version: 0.5.3
  • OS: Arch Linux + Windows 10

tiehuis avatar Mar 02 '17 08:03 tiehuis

Interesting - are you saying that this begun happening after the latest vscode release?

Until we solve this correctly, you can use the workaround found here https://github.com/VSCodeVim/Vim/issues/907#issuecomment-264738452 to redefine c-u and c-d. A lot of people rely on these motions, so we'll try to get there quickly!

johnfn avatar Mar 02 '17 12:03 johnfn

Upgrading to Visual Studio Code Version 1.10.1 did not fix this for me on macOS.

JessThrysoee avatar Mar 02 '17 17:03 JessThrysoee

@johnfn "Interesting - are you saying that this begun happening after the latest vscode release?"

Yes, this behavior just started with 1.10.1. I was using the Insiders release and noticed something funky but it didn't really hit me until I updated to 1.10.1 non-Insiders earlier today.

gwojan avatar Mar 02 '17 21:03 gwojan

FWIW I have this problem on 1.10.0. I haven't yet restarted to update to 1.10.1.

rhys-vdw avatar Mar 02 '17 23:03 rhys-vdw

I guess I should've mentioned I did not see the problem on 1.9.1. πŸ˜‰

gwojan avatar Mar 02 '17 23:03 gwojan

It sounds a lot like this is a regression in VSCode itself. I was able to confirm this by testing on 1.9.0, in which C-d and C-u worked correctly.

We've got our best men (aka @rebornix) on it. :)

johnfn avatar Mar 03 '17 06:03 johnfn

It seems this problem is resolved in VSCode 1.10.2.

shinymimiq avatar Mar 09 '17 06:03 shinymimiq

@johnfn I'm still not sure scrolling is working correctly. Ctrl-d, Ctrl-u, Ctrl-f, Ctrl-b do not scroll down like gvim.

With the cursor at the start of the document pressing Ctrl-f locates the cursor at the bottom of the screen. Pressing Ctrl-f a second time moves the current line to the top of the visual window.

Ctrl-f in gvim scrolls by one screen-height of text with each press. I'm currently using Windows 7 and haven't checked Windows 10 yet.

gwojan avatar Mar 09 '17 15:03 gwojan

The fun part is setting below keybindings

    {
        "key": "ctrl+f",
        "command": "editorScroll",
        "when": "editorTextFocus",
        "args": {
            "to": "down",
            "value": 1,
            "by": "page",
            "revealCursor": true
        }
    }

is perfect. However in Vim, we just call this command but the behavior is different. I'll take a look.

rebornix avatar Mar 09 '17 16:03 rebornix

If you think ctrl-d and ctrl-u have gotten WORSE as compared to before this specific bug was introduced, please thumbs this specific comment up. (I don't use them at all, so I wouldn't know.)

We know they're still not really optimal. That is unfortunately a limit of vscode right now.

johnfn avatar Mar 18 '17 09:03 johnfn

Can confirm on VSCode 1.11.2 with vscodevim 0.6.20; <C d> <C u> will move the cursor half a page down, which only moves the page down every other time I press it. 😒This seems to be the same behavior @gwojan observed with <C f>.

Edit: Also <C e> and <C y> don't scroll the page when the cursor is at an edge for me. ie when my cursor is at the first visible line, <C e> does nothing, and likewise when my cursor is at the bottom of the screen <C y> does nothing.

snewell92 avatar Apr 28 '17 14:04 snewell92

@snewell92 Is the <C-e> and <C-y> resolved for you now? It was reported somewhere else, and they reported that the most recent vscode release fixed that issue.

Chillee avatar May 22 '17 09:05 Chillee

Yep! Can confirm resolution. Tyvm <3<3

snewell92 avatar May 22 '17 14:05 snewell92

I don't really get what the bug is here. I can't really replicate the exact bugs that most people are talking about with <c-d>.

I do have the issue where <c-d> moves the cursor to the top of the screen, but that seems like more this issue: https://github.com/VSCodeVim/Vim/issues/1348

Chillee avatar Jun 20 '17 11:06 Chillee

@Chillee did you mean to reference another issue, you linked to this issue.

Originally @tiehuis said

The cursor should retain its relative position on the screen [when using

I was trying to generalize the problem to see if there was an underlying problem with how navigation movements worked, but that doesn't appear to be the case.

It seems to me that the this issue is now focused on the cursor position in <c-d> and <c-u>.

snewell92 avatar Jun 21 '17 13:06 snewell92

Oh I meant to link a different issue: https://github.com/VSCodeVim/Vim/issues/810

Chillee avatar Jun 21 '17 16:06 Chillee

Stopped working with 1.15 but updated to 1.15.1 its working again.

jroboyd avatar Aug 18 '17 08:08 jroboyd

This needs reopening.

I am finding this issue occur on certain files but not others. One html file that I have the behaviour described at the top of this post occurs, but on another html file works perfectly.

Intermittent issue but it is consistent with the file. Tried opening and closing VS Code closing the file and reopening.

Nothing really special about the file in question, just a html file with angularjs, it is 556 lines long if that is a factor. Copy pasted code into a new file, the new file had no issues. This is strange! Opening the file in split screen and the issue disappears with the file.

VS Code version: 1.15.1 vscodevim version: v0.10.0 windows 10

jroboyd avatar Sep 04 '17 09:09 jroboyd

@boydy12 This issue doesn't seem to be closed to me?

I think it's a vscode limitation; hold off on that while I check though.

Chillee avatar Sep 04 '17 21:09 Chillee

As a workaround you can define those bindings:

{
    "before": ["<C-d>"],
    "after": ["j","j","j","j","j","j","j","j"]
},
{
    "before": ["<C-u>"],
    "after": ["k","k","k","k","k","k","k","k"]
}

Looks weird, but works :)

rpeshkov avatar Sep 26 '17 21:09 rpeshkov