VSCodeVim / Vim

:star: Vim for Visual Studio Code
http://aka.ms/vscodevim
MIT License
13.86k stars 1.31k forks source link

Relative line number jumps don't work #6550

Open AbhinavBajaj opened 3 years ago

AbhinavBajaj commented 3 years ago
Please thumbs-up 👍 this issue if it personally affects you! You can do this by clicking on the emoji-face on the top right of this post. Issues with more thumbs-up will be prioritized.

Commands like number + j or number + k take you to the wrong line number.

Steps to reproduce

1) Open any file > 20 lines of code 2) In Normal mode type 14j or 14k (use any number greater than 12) 3) Notice how the cursor jumps more than 14 lines

Please let me know if you need more steps to reproduce

Screen Shot 2021-04-25 at 2 04 37 PM

Cursor on absolute line 43

Screen Shot 2021-04-25 at 2 04 54 PM

Command ran 14k

Technical details:

VSCode Version: 1.55.2 VsCodeVim Version: 1.20.0 OS: MacOS 11.2.3

settings.json

{
    "editor.cursorBlinking": "phase",
    "editor.tabSize": 2,
    "editor.roundedSelection": true,
    "editor.glyphMargin": true,
    "editor.fontSize": 12,
    "editor.rulers": [
        100
    ],
    "editor.renderIndentGuides": true,
    "editor.formatOnSave": true,
    "editor.formatOnType": true,
    "editor.scrollBeyondLastLine": false,
    "editor.minimap.enabled": false,
    "editor.wordWrap": "wordWrapColumn",
    "files.exclude": {
        //"**/.tmp": true,
        "bazel-*": true,
        "pkg*": true,
        ".venv": true,
        "**/vendor": true,
        "**/.git": true,
        "**/.DS_Store": true,
        "go-build/.go": true,
        ".vscode": true,
        "env": true,
        "env_docs": true,
        "udeploy": true,
        "debian": true,
        "**/*.test": true,
        "**/*.pyc": true,
        "Godeps/_workspace": true,
        "**/coverage.html": true,
        "**/_build": true,
        "**/*.coverprofile": true,
        "**/__pycache__": true
    },
    "go.inferGopath": false,
    "go.gopath": "/${env:HOME}/gocode",
    "go.goroot": "/usr/local/go",
    "go.toolsGopath": "/usr/local/go/pkg/tool/darwin_amd64",
    "go.toolsEnvVars": {
        "GO111MODULE": "off",
    },
    "go.useLanguageServer": true,
    "files.watcherExclude": {
        "bazel-*": true,
        "pkg*": true,
    },
    "eslint.alwaysShowStatus": true,
    "eslint.format.enable": true,
    "editor.largeFileOptimizations": false,
    "files.trimTrailingWhitespace": true,
    "files.autoSave": "onFocusChange",
    "files.insertFinalNewline": true,
    "go.autocompleteUnimportedPackages": true,
    "go.lintTool": "golint",
    "go.lintFlags": [
        "--fast",
        "--enable=errcheck"
    ],
    "go.vetFlags": [
        "-printfuncs=wrapf,statusf,warnf,infof,debugf,noerrorf,equalf,newexiterrorf,containsf,truef,falsef,equalf,emptyf,failf"
    ],
    "python.linting.enabled": true,
    "python.linting.flake8Enabled": true,
    "python.linting.pylintEnabled": false,
    "python.linting.lintOnSave": true,
    "[python]": {
        "editor.tabSize": 4
    },
    "window.titleBarStyle": "custom",
    //"python.formatting.provider": "yapf",
    "vim.useCtrlKeys": true,
    "vim.enableNeovim": true,
    "vim.insertModeKeyBindings": [
        {
            "before": [
                "k",
                "j"
            ],
            "after": [
                "<Esc>"
            ]
        }
    ],
   "vim.normalModeKeyBindingsNonRecursive": [
        {
            "before": [
                "j"
            ],
            "commands": [
                {
                    "command": "accelerated.cursorDown"
                }
            ]
        },
        {
            "before": [
                "k"
            ],
            "commands": [
                {
                    "command": "accelerated.cursorUp"
                }
            ]
        },
        {
            "before": [
                "n"
            ],
            "after": [
                "k"
            ]
        },
        {
            "before": [
                "t"
            ],
            "after": [
                "j"
            ]
        },
        {
            "before": [
                "s"
            ],
            "after": [
                "l"
            ]
        },
        {
            "before": [
                ",",
                "w"
            ],
            "after": [
                ":",
                "w"
            ]
        }
    ],
    "accelerated.accelerationTable": [
        12,
        17,
        21,
        24,
        26,
        28,
        30
    ],
    "[cpp]": {
        "editor.quickSuggestions": false
    },
    "[c]": {
        "editor.quickSuggestions": false
    },
    // https://github.com/Microsoft/vscode/issues/23991
    "keyboard.dispatch": "keyCode",
    "editor.fontFamily": "'Ubuntu Mono', 'monospace', monospace, 'Droid Sans Fallback'",
    "workbench.activityBar.visible": false,
    "materialTheme.autoApplyIcons": true,
    "telemetry.enableTelemetry": false,
    "editor.wordWrapColumn": 100,
    "breadcrumbs.enabled": true,
    "go.formatTool": "goimports",
    "launch": {
        "configurations": [],
        "compounds": []
    },
    "go.delveConfig": {
        "dlvLoadConfig": {
            "followPointers": true,
            "maxVariableRecurse": 1,
            "maxStringLen": 64,
            "maxArrayValues": 64,
            "maxStructFields": -1
        },
        "apiVersion": 2,
        "showGlobalVariables": false
    },
    "notebook.kernelProviderAssociations": [],
    "go.alternateTools": {},
    "json.schemas": [],
    "[javascript]": {
        "editor.defaultFormatter": "dbaeumer.vscode-eslint"
    },
    "javascript.updateImportsOnFileMove.enabled": "always",
    "gitlens.currentLine.dateFormat": "",
    "editor.fontLigatures": false,
    "[javascriptreact]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    "editor.lineNumbers": "relative",
}
J-Fields commented 3 years ago

Can you provide your config please?

AbhinavBajaj commented 3 years ago

Can you provide your config please?

Updated issue, thanks for looking into it

AbhinavBajaj commented 3 years ago

Any update on this?

J-Fields commented 3 years ago

The issue is these bindings:

        {
            "before": [
                "j"
            ],
            "commands": [
                {
                    "command": "accelerated.cursorDown"
                }
            ]
        },
        {
            "before": [
                "k"
            ],
            "commands": [
                {
                    "command": "accelerated.cursorUp"
                }
            ]
        },

When you map a key to a VSCode command, we don't call that command [count] times. Maybe we should? In this case, though, it wouldn't do what you want, because it'll act as if you hit j or k 15 times very quickly, and the other plugin would move your cursor multiple times for the last handful, so you'll go up/down more than 15 lines.