fix(vim): text inserted position error when completion ends with empty line. (#346)

release-0.0
Zhiming Ma 2023-08-09 18:29:06 +08:00 committed by GitHub
parent d89d5aeef2
commit 3052ad4450
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 4 deletions

View File

@ -410,13 +410,14 @@ function! tabby#Show()
return
endif
let lines = split(choice.text, "\n")
" split will not give an empty line if text starts with "\n" or ends with "\n"
" split will not give an empty line if text starts with "\n"
if choice.text[0] == "\n"
call insert(lines, '')
endif
if choice.text[-1] == "\n"
call add(lines, '')
endif
" ignore trailing empty lines
while len(lines) > 0 && (lines[-1] == '')
call remove(lines, -1)
endwhile
call tabby#virtual_text#Show(lines)
let s:shown_lines = lines
call s:PostEvent('view')