From 3052ad4450d1bd5889deea8b27573dae81185e37 Mon Sep 17 00:00:00 2001 From: Zhiming Ma Date: Wed, 9 Aug 2023 18:29:06 +0800 Subject: [PATCH] fix(vim): text inserted position error when completion ends with empty line. (#346) --- clients/vim/autoload/tabby.vim | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/clients/vim/autoload/tabby.vim b/clients/vim/autoload/tabby.vim index efa21c5..8a8ab54 100644 --- a/clients/vim/autoload/tabby.vim +++ b/clients/vim/autoload/tabby.vim @@ -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')