Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Line Motion Invalid argument -1 #484

Open
Nealium opened this issue Jul 31, 2022 · 2 comments · Fixed by timsu92/vim-easymotion#2 · May be fixed by #488
Open

Line Motion Invalid argument -1 #484

Nealium opened this issue Jul 31, 2022 · 2 comments · Fixed by timsu92/vim-easymotion#2 · May be fixed by #488

Comments

@Nealium
Copy link

Nealium commented Jul 31, 2022

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 * b3cfab2*
  • 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
Copy link
Author

Nealium commented Aug 1, 2022

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
            "}}}

timsu92 added a commit to timsu92/vim-easymotion that referenced this issue Aug 29, 2022
timsu92 added a commit to timsu92/vim-easymotion that referenced this issue Aug 29, 2022
@davinosuke
Copy link

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.

zdy023 added a commit to zdy023/vim-easymotion that referenced this issue Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants