easymotion / vim-easymotion

Vim motions on speed!
http://www.vim.org/scripts/script.php?script_id=3526
7.51k stars 361 forks source link

Line Motion Invalid argument -1 #484

Open Nealium opened 2 years ago

Nealium commented 2 years ago

Using the (leader)j or (leader)k sometimes breaks. More than likely it's due to me upgrading to Vim 9.0, my odd tabbing of JQuery objects and the folding I've provided a js file snippet at the bottom, from the last time I ran into the error, I just trimmed the fat a bit.

Error Message

EasyMotion: Vim(call):E475: Invalid argument: -1 : function EasyMotion#jk[5]..<SNR>63_EasyMotion, line 109

System

field value
os Windows 10 Pro 21H1
vim Vim 9.0 2022 Jun 28
locale C.UTF-8
easymotion b3cfab2a6302b3b39f53d9fd2cd997e1127d7878

Min Vimrc

set wrap
set linebreak
set breakindent
filetype indent on

set autoindent
set smartindent
set expandtab

au BufNewFile,BufRead *
    \ set tabstop=2 |
    \ set softtabstop=2 |
    \ set shiftwidth=2

set foldmethod=indent
set foldlevel=99

set nocompatible
filetype plugin on
syntax on

" EasyMotion: https://github.com/easymotion/vim-easymotion
let g:EasyMotion_do_mapping = 0 " Disable default mappings

"   Jumps:
nmap <Leader>s <Plug>(easymotion-overwin-f)

let g:EasyMotion_smartcase = 1

" JK motions: Line motions
map <Leader>j <Plug>(easymotion-j)
map <Leader>k <Plug>(easymotion-k)

Recreating

  1. Fold line 19 ( :19 + za )
  2. Goto Line 15 and hit (leader)j (:15 \j)
    • it's not specifically on line 15, it's the area, but that's what I originally hit
    • Note: \k works from this area, but sometimes it's flipped \k is broken and \j works
      $(document).ready(function() {
      if (blah.exists){
      $('#submit').click(function(){
      $.ajax({
      method: 'post',
      url: '/form_submit’,
      data: {},
      success: function(data){
        if (data['status']){
          $('<tr></tr>')
            .append(
              $('<th></th>')
                .append(
                  $('<input></input>')
                    .addClass('buglocation') // \j on this line
                )
            )
            .append(
              $('<th></th>') // fold right here
                .append(
                  $('<input></input>')
                )
            )
        }
      }
      });
      };
      };
      });

Folded = Broken

image

Unfolded = works

image

edit: fixed missing quote in code block

Nealium commented 2 years ago

Update

On the example I gave if I tab over line 23 once, the issue doesn't happen- I knew it was my tabs :(

after tinkering: slightly editing it to double check that it's skipping lines that are inside folds, seems to fix the issue.

Original

davinosuke commented 1 year ago

I have recently started using EasyMotion, and I am experiencing the same issue, but with all commands. Whenever a fold exists in the forward search direction, EasyMotion fails with a message similar to that in the OP.

I am using freshly updated versions of vim (9.0.1302) and EasyMotion. Before I updated the errors occurred in both directions, but now it only happens with forward searches. Backward motions all seem to work fine.

The only changes I have made to the default configuration are setting use_upper and some color tweaks.