diff --git a/autoload/ale/hover.vim b/autoload/ale/hover.vim index 1202e08e..a42766eb 100644 --- a/autoload/ale/hover.vim +++ b/autoload/ale/hover.vim @@ -117,10 +117,10 @@ function! ale#hover#ParseLSPResult(contents) abort for l:line in split(l:item, "\n") if l:fence_language is v:null " Look for the start of a code fence. (```python, etc.) - let l:match = matchlist(l:line, '^``` *\([^ ]\+\) *$') + let l:match = matchlist(l:line, '^``` *\([^ ]\+\)\? *$') if !empty(l:match) - let l:fence_language = l:match[1] + let l:fence_language = len(l:match) > 1 ? l:match[1] : 'text' if !empty(l:marked_list) call add(l:fence_lines, '') diff --git a/test/test_hover_parsing.vader b/test/test_hover_parsing.vader index 81db1da3..b9e56de8 100644 --- a/test/test_hover_parsing.vader +++ b/test/test_hover_parsing.vader @@ -12,6 +12,22 @@ Execute(Invalid results should be handled): AssertEqual [[], []], ale#hover#ParseLSPResult({'kind': 'x', 'value': 'xxx'}) Execute(A string with a code fence should be handled): + AssertEqual + \ [ + \ [ + \ ], + \ [ + \ 'def foo():', + \ ' pass', + \ ], + \ ], + \ ale#hover#ParseLSPResult(join([ + \ '```', + \ 'def foo():', + \ ' pass', + \ '```', + \ ], "\n")) + AssertEqual \ [ \ [