From a5d1663185bee20bfb120c9ab212144444514982 Mon Sep 17 00:00:00 2001 From: Jaehwang Jerry Jung Date: Sat, 29 May 2021 20:00:30 +0900 Subject: [PATCH] Fix multibyte character bug in block comment (#469) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit NERDCommenterComment using block comment on visual block whose last char is unicode breaks up the unicode char. Example: a가 → /* a */<80> To fix this, add the character's byte length to the index used for chopping the right part of the text block to be commented. --- plugin/NERD_commenter.vim | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugin/NERD_commenter.vim b/plugin/NERD_commenter.vim index 9582ca9..17b9d43 100644 --- a/plugin/NERD_commenter.vim +++ b/plugin/NERD_commenter.vim @@ -750,7 +750,9 @@ function s:CommentBlock(top, bottom, lSide, rSide, forceNested ) if s:Multipart() "stick the right delimiter down - let theLine = strpart(theLine, 0, rSide+strlen(leftSpaced)) . rightSpaced . strpart(theLine, rSide+strlen(leftSpaced)) + "byte idx of the char next to the last char = (byte idx of last char + 1) + (last char byte len) - 1 + let rIndex = (rSide+strlen(leftSpaced)) + strlen(strcharpart(strpart(theLine, rSide+strlen(leftSpaced)-1), 0, 1)) - 1 + let theLine = strpart(theLine, 0, rIndex) . rightSpaced . strpart(theLine, rIndex) let firstLeftDelim = s:FindDelimiterIndex(s:Left(), theLine) let lastRightDelim = s:LastIndexOfDelim(s:Right(), theLine)