-
Notifications
You must be signed in to change notification settings - Fork 41
Crash with multiple languages in spelllang. #99
Copy link
Copy link
Open
Description
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:
vim-grammarous/autoload/grammarous.vim
Lines 275 to 284 in db46357
| 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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels