From c5a7df79a7692c044cb69e38c7c6b71f44d4656d Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 26 Jan 2024 07:03:24 +0800 Subject: vim-patch:9.1.0056: wrong number of trailing spaces inserted after blockwise put Problem: Incorrect number of trailing spaces inserted for multibyte characters when pasting a blockwise register in blockwise visual mode (VanaIgr) Solution: Skip over trailing UTF-8 bytes when computing the number of trailing spaces (VanaIgr) When pasting in blockwise visual mode, and the register type is , Vim aligns the text after the replaced area by inserting spaces after pasted lines that are shorter than the longest line. When a shorter line contains multibyte characters, each trailing UTF-8 byte's width is counted in addition to the width of the character itself. Each trailing byte counts as being 4 cells wide (since it would be displayed as ). closes: vim/vim#13909 https://github.com/vim/vim/commit/6638ec8afa9875ff565020536954c424d5f6f27d Co-authored-by: VanaIgr --- test/old/testdir/test_put.vim | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'test') diff --git a/test/old/testdir/test_put.vim b/test/old/testdir/test_put.vim index 6c4bd28386..69fd4643c1 100644 --- a/test/old/testdir/test_put.vim +++ b/test/old/testdir/test_put.vim @@ -12,6 +12,16 @@ func Test_put_block() bwipe! endfunc +func Test_put_block_unicode() + new + call setreg('a', "À\nÀÀ\naaaaaaaaaaaa", "\") + call setline(1, [' 1', ' 2', ' 3']) + exe "norm! \jj\"ap" + let expected = ['À 1', 'ÀÀ 2', 'aaaaaaaaaaaa3'] + call assert_equal(expected, getline(1, 3)) + bw! +endfunc + func Test_put_char_block() new call setline(1, ['Line 1', 'Line 2']) -- cgit