summaryrefslogtreecommitdiff
path: root/src/ops.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-01-20 12:10:48 +0000
committerBram Moolenaar <Bram@vim.org>2022-01-20 12:10:48 +0000
commit57df9e8a9f9ae1aafdde9b86b10ad907627a87dc (patch)
treefc05bc4dfe2ff3b836ab20722b1cc3b7557aec48 /src/ops.c
parent8aa0e6c60da5f7a4b04eaead40d183fd8e5640a4 (diff)
downloadvim-git-57df9e8a9f9ae1aafdde9b86b10ad907627a87dc.tar.gz
patch 8.2.4151: reading beyond the end of a linev8.2.4151
Problem: Reading beyond the end of a line. Solution: For block insert only use the offset for correcting the length.
Diffstat (limited to 'src/ops.c')
-rw-r--r--src/ops.c19
1 files changed, 2 insertions, 17 deletions
diff --git a/src/ops.c b/src/ops.c
index a99680249..e0fa344d8 100644
--- a/src/ops.c
+++ b/src/ops.c
@@ -529,24 +529,9 @@ block_insert(
}
if (has_mbyte && spaces > 0)
- {
- int off;
+ // avoid copying part of a multi-byte character
+ offset -= (*mb_head_off)(oldp, oldp + offset);
- // 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;
- }
- }
if (spaces < 0) // can happen when the cursor was moved
spaces = 0;