Fix UTF-8 corruption when pasting at multibyte character

col('.') is the first byte of the character under the cursor, so splitting
the line there left one byte in head and the rest in tail. Advance past the
whole character instead.

Close #1627
This commit is contained in:
Junegunn Choi
2026-09-26 17:04:35 +09:00
parent 8a0068127a
commit a630ef91e1
+4 -1
View File
@@ -498,7 +498,10 @@ function! fzf#vim#paste(items) abort
return s:warn('Cannot paste into a nomodifiable buffer')
endif
let line = getline('.')
let idx = empty(line) ? 0 : col('.')
" col('.') is the first byte of the character under the cursor. Skip the
" whole character so that a multibyte character is not split in half.
let cursor = col('.') - 1
let idx = empty(line) ? 0 : cursor + strlen(matchstr(line, '.', cursor))
let head = strpart(line, 0, idx)
let tail = strpart(line, idx)
let pad = (!empty(head) && head !~ '\s$') ? ' ' : ''