mirror of
https://github.com/junegunn/fzf.vim.git
synced 2026-09-27 06:02:22 +08:00
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:
@@ -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$') ? ' ' : ''
|
||||
|
||||
Reference in New Issue
Block a user