diff src/ops.c @ 27245:776db9e02b61 v8.2.4151

patch 8.2.4151: reading beyond the end of a line Commit: https://github.com/vim/vim/commit/57df9e8a9f9ae1aafdde9b86b10ad907627a87dc Author: Bram Moolenaar <Bram@vim.org> Date: Thu Jan 20 12:10:48 2022 +0000 patch 8.2.4151: reading beyond the end of a line Problem: Reading beyond the end of a line. Solution: For block insert only use the offset for correcting the length.
author Bram Moolenaar <Bram@vim.org>
date Thu, 20 Jan 2022 13:15:04 +0100
parents be5e01f3ee3b
children 93d4ee1e6113
line wrap: on
line diff
--- a/src/ops.c
+++ b/src/ops.c
@@ -529,24 +529,9 @@ block_insert(
 	}
 
 	if (has_mbyte && spaces > 0)
-	{
-	    int off;
-
-	    // Avoid starting halfway a multi-byte character.
-	    if (b_insert)
-	    {
-		off = (*mb_head_off)(oldp, oldp + offset + spaces);
-		spaces -= off;
-		count -= off;
-	    }
-	    else
-	    {
-		// spaces fill the gap, the character that's at the edge moves
-		// right
-		off = (*mb_head_off)(oldp, oldp + offset);
-		offset -= off;
-	    }
-	}
+	    // avoid copying part of a multi-byte character
+	    offset -= (*mb_head_off)(oldp, oldp + offset);
+
 	if (spaces < 0)  // can happen when the cursor was moved
 	    spaces = 0;