vim-easymotion icon indicating copy to clipboard operation
vim-easymotion copied to clipboard

Line Motion Invalid argument -1

Open Nealium opened this issue 3 years ago • 3 comments

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*
  • Note: only started when upgraded

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

  • I've created a condensed js file, that's raising the error always after follow steps:
  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 avatar Jul 31 '22 19:07 Nealium

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

  • autoload/EasyMotion.vim around line ~1037
            " Skip folded lines {{{
            if EasyMotion#helper#is_folded(pos[0])
                if search_direction ==# 'b'
                    " FIXME: Hmm... I should use filter()
                    " keepjumps call cursor(foldclosed(pos[0]), 0)
                else
                    keepjumps call cursor(foldclosedend(pos[0]+1), 0)
                endif
            else
                call add(targets, pos)
            endif
            "}}}

Edited

            " Skip folded lines {{{
            if EasyMotion#helper#is_folded(pos[0])
                if search_direction ==# 'b'
                    " FIXME: Hmm... I should use filter()
                    " keepjumps call cursor(foldclosed(pos[0]), 0)
                else
                    if foldclosedend(pos[0]+1) != -1
                        keepjumps call cursor(foldclosedend(pos[0]+1), 0)
                    endif
                endif
            else
                call add(targets, pos)
            endif
            "}}}

Nealium avatar Aug 01 '22 03:08 Nealium

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.

davinosuke avatar Feb 12 '23 14:02 davinosuke