Skip to content

Commit e346c77

Browse files
tsufekiprabirshrestha
authored andcommitted
Fix newline in completion popup. (#369)
* Fix newline in completion popup. * Add test.
1 parent fe2ec6e commit e346c77

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

autoload/lsp/omni.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ function! lsp#omni#get_vim_completion_item(item, ...) abort
223223
endif
224224

225225
if has_key(a:item, 'detail') && !empty(a:item['detail'])
226-
let l:completion['menu'] = a:item['detail']
226+
let l:completion['menu'] = substitute(a:item['detail'], '[ \t\n\r]\+', ' ', 'g')
227227
endif
228228

229229
if has_key(a:item, 'documentation')

test/lsp/omni.vimspec

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,5 +93,28 @@ Describe lsp#omni
9393

9494
Assert Equals(got, want)
9595
End
96+
97+
It should return item with newlines in 'menu' replaced
98+
let item = {
99+
\ 'label': 'my-label',
100+
\ 'documentation': 'my documentation.',
101+
\ 'detail': "my-detail\nmore-detail",
102+
\ 'kind': '3'
103+
\}
104+
105+
let want = {
106+
\ 'word': 'my-label',
107+
\ 'abbr': 'my-label',
108+
\ 'info': 'my documentation.',
109+
\ 'icase': 1,
110+
\ 'dup': 1,
111+
\ 'empty': 1,
112+
\ 'kind': 'function',
113+
\ 'menu': 'my-detail more-detail'
114+
\}
115+
let got = lsp#omni#get_vim_completion_item(item)
116+
117+
Assert Equals(got, want)
118+
End
96119
End
97120
End

0 commit comments

Comments
 (0)