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

List index out of range caused by missing priority in sign place output #406

Closed
serpent7776 opened this issue May 8, 2023 · 0 comments · Fixed by #407
Closed

List index out of range caused by missing priority in sign place output #406

serpent7776 opened this issue May 8, 2023 · 0 comments · Fixed by #407

Comments

@serpent7776
Copy link

I got hit by an error opening a file with sign marks

Error detected while processing function <SNR>89_callback_vim_close[9]..<SNR>89_handle_diff[32]..sy#sign#set_signs[20]..sy#sign#process_diff[5]..sy#sign#get_current_signs[4]..sy#util#get_signs:
line   10:
E684: List index out of range: 1
E116: Invalid arguments for function str2nr(tokens[1])
E15: Invalid expression: str2nr(tokens[1])
line   11:
E684: List index out of range: 2
E116: Invalid arguments for function str2nr(tokens[2])
E15: Invalid expression: str2nr(tokens[2])
line   12:
E684: List index out of range: 3
E15: Invalid expression: tokens[3]
line   13:
E684: List index out of range: 4
E116: Invalid arguments for function str2nr(tokens[4])
E15: Invalid expression: str2nr(tokens[4])
line   15:
E121: Undefined variable: line
E116: Invalid arguments for function add

script 89 is this one:

 89: ~/.vim/plugged/vim-signify/autoload/sy/repo.vim

The issue seems to be with regex passed to matchlist here:

let tokens = matchlist(signline, '\v^\s+\S+\=(\d+)\s+\S+\=(\d+)\s+\S+\=(.*)\s+\S+\=(\d+)$')

When I execute sign place buffer=n on a problematic file I get

--- Signs ---
Signs for util.vim:
    line=247  id=263  name=SignifyAdd
    line=247  id=261  name=SignifyAdd
    line=247  id=259  name=SignifyAdd
    line=247  id=258  name=SignifyAdd
    line=247  id=257  name=SignifyAdd
    line=247  id=256  name=SignifyAdd
    line=249  id=264  name=SignifyAdd
    line=249  id=262  name=SignifyAdd
    line=249  id=260  name=SignifyAdd

On different machine that doesn't have this issue the result is different (it's for different file):

--- Signs ---
Signs for README.md:
    line=44  id=256  name=SignifyAdd  priority=10
    line=45  id=257  name=SignifyAdd  priority=10
    line=46  id=258  name=SignifyAdd  priority=10
    line=47  id=259  name=SignifyAdd  priority=10
    line=48  id=260  name=SignifyAdd  priority=10

Looks like priority is missing and that's why regex doesn't match.

If I change regex to '\v^\s+\S+\=(\d+)\s+\S+\=(\d+)\s+\S+\=(\w+)(\s+\S+\=(\d+))?$' and bump the index when assigning to priority variable (let priority = str2nr(tokens[5])) it works fine for me, but that's probably not an acceptable fix to the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant