From a630ef91e1e050574e703f506cd0812b18d26939 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Sat, 26 Sep 2026 17:04:35 +0900 Subject: [PATCH] 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 --- autoload/fzf/vim.vim | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/autoload/fzf/vim.vim b/autoload/fzf/vim.vim index 6e23872..509cd08 100755 --- a/autoload/fzf/vim.vim +++ b/autoload/fzf/vim.vim @@ -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$') ? ' ' : ''