Skip to content

Commit c0e2e39

Browse files
committed
bugfix for #318
1 parent f6d725c commit c0e2e39

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

autoload/easycomplete/popup.vim

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,20 @@ function! s:GetCurrentLineLastCharToWindowRightEdgeDistance()
126126
return winwidth(0) - wincol() - s:GetCusorToLineRightEdgeDistance() + 1
127127
endfunction
128128

129+
function! s:CurrCharIsChinese()
130+
let offset = 0
131+
let l_len = strwidth(strpart(getline('.'), col('.')-1, 3))
132+
if l_len == 2
133+
let offset = 1 " 是中文字符
134+
else
135+
let offset = 0 " 不是中文字符
136+
endif
137+
return offset
138+
endfunction
139+
129140
function! s:GetCusorToLineRightEdgeDistance()
130-
return strchars(getline('.')) - virtcol('.') + 1
141+
let offset = s:CurrCharIsChinese()
142+
return strwidth(getline('.')) - virtcol('.') + 1 + offset
131143
endfunction
132144

133145
function! s:lint(content, hl, ft)
@@ -192,7 +204,7 @@ function! easycomplete#popup#float(content, hl, direction, ft, offset, float_typ
192204
let float_maxwidth = g:easycomplete_popup_width
193205
endif
194206
let content = easycomplete#util#ModifyInfoByMaxwidth(content, float_maxwidth)
195-
if len(content) == 1 && strlen(content[0]) == 0
207+
if len(content) == 1 && strwidth(content[0]) == 0
196208
return
197209
endif
198210
let prevw_width = easycomplete#popup#DisplayWidth(content, float_maxwidth)

0 commit comments

Comments
 (0)