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

Crash with multiple languages in spelllang. #99

Open
kevincox opened this issue Jun 23, 2021 · 0 comments
Open

Crash with multiple languages in spelllang. #99

kevincox opened this issue Jun 23, 2021 · 0 comments

Comments

@kevincox
Copy link

Error detected while processing function grammarous#check_current_buffer[23]..<SNR>81_invoke_check:       
line   39:
E121: Undefined variable: lang
E116: Invalid arguments for function printf
E15: Invalid expression: printf(   '-c %s -l %s --api %s',   &fileencoding ? &fileencoding : &encoding,   lang,   s
ubstitute(tmpfile, '\\\s\@!', '\\\\', 'g') )
line   48:
E121: Undefined variable: cmdargs
E15: Invalid expression: '-d ' . join(disabled_rules, ',') . ' ' . cmdargs
line   67:
E121: Undefined variable: cmdargs
E116: Invalid arguments for function printf
E15: Invalid expression: printf('%s %s', g:grammarous#languagetool_cmd, cmdargs)
line   86:
E121: Undefined variable: cmd
E116: Invalid arguments for function jobstart
E15: Invalid expression: jobstart(cmd, opts)
line   87:
E121: Undefined variable: job

This appears to occur because there is a path through the function where lang does not get defined:

if g:grammarous#use_vim_spelllang
" Convert vim spelllang to languagetool spelllang
if len(split(&spelllang, '_')) == 1
let lang = split(&spelllang, '_')[0]
elseif len(split(&spelllang, '_')) == 2
let lang = split(&spelllang, '_')[0].'-'.toupper(split(&spelllang, '_')[1])
endif
else
let lang = a:0 == 1 ? g:grammarous#default_lang : a:1
endif

It appears that there should be a fallback for =0 (use default_lang?) and >2 segments (raise an error?).

This problem seems to be occurring because I have multiple languages listed in my spelllang which is allowed.

:echo &spelllang
en_ca,en_us,en
:echo split(&spelllang, '_')
['en', 'ca,en', 'en']

I think the best solution is to only consider the first element of spelllang.

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

No branches or pull requests

1 participant