Skip to content

Commit c9cc333

Browse files
committed
Do not fail loudly during completion
1 parent 9e260fd commit c9cc333

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

autoload/composer.vim

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ endfunction
7171
function! s:json_parse(string) abort
7272
try
7373
return projectionist#json_parse(a:string)
74+
catch /^invalid JSON/
75+
call s:throw('composer.json cannot be parsed')
7476
catch /^Vim\%((\a\+)\)\=:E117/
7577
call s:throw('projectionist is not available')
7678
endtry
@@ -415,11 +417,21 @@ function! composer#complete(A, L, P) abort
415417
endif
416418

417419
if empty(help) && index(['depends', 'remove', 'update', 'suggests'], subcommand) >= 0
418-
let candidates = candidates + keys(s:project().packages_required())
420+
try
421+
let candidates = candidates + keys(s:project().packages_required())
422+
catch
423+
" Fail silently when composer.json cannot be parsed because of missing
424+
" dependency or invalid/empty file.
425+
endtry
419426
endif
420427

421428
if empty(help) && index(['run-script', ''], subcommand) >= 0
422-
let candidates = candidates + keys(s:project().scripts())
429+
try
430+
let candidates = candidates + keys(s:project().scripts())
431+
catch
432+
" Fail silently when composer.json cannot be parsed because of missing
433+
" dependency or invalid/empty file.
434+
endtry
423435
endif
424436

425437
if empty(help) && index(['browse', 'home', 'require', 'show'], subcommand) >= 0 && !empty(a:A)

0 commit comments

Comments
 (0)