From 540264306b6340bdd8133cd3307b169f7708c4d6 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Wed, 26 Jan 2022 16:47:39 +0100 Subject: vim-patch:8.2.4219: reading before the start of the line Problem: Reading before the start of the line. Solution: Check boundary before trying to read the character. https://github.com/vim/vim/commit/44db8213d38c39877d2148eff6a72f4beccfb94e --- src/nvim/ops.c | 2 +- src/nvim/testdir/test_visual.vim | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 2bc92ce295..b2554cbf0d 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -2801,7 +2801,7 @@ static void yank_copy_line(yankreg_T *reg, struct block_def *bd, size_t y_idx, if (exclude_trailing_space) { int s = bd->textlen + bd->endspaces; - while (ascii_iswhite(*(bd->textstart + s - 1)) && s > 0) { + while (s > 0 && ascii_iswhite(*(bd->textstart + s - 1))) { s = s - utf_head_off(bd->textstart, bd->textstart + s - 1) - 1; pnew--; } diff --git a/src/nvim/testdir/test_visual.vim b/src/nvim/testdir/test_visual.vim index 8520c8e900..b087c88c35 100644 --- a/src/nvim/testdir/test_visual.vim +++ b/src/nvim/testdir/test_visual.vim @@ -1103,6 +1103,13 @@ func Test_visual_put_blockedit_zy_and_zp() bw! endfunc +func Test_visual_block_yank_zy() + new + " this was reading before the start of the line + exe "norm o\\\zy" + bwipe! +endfunc + func Test_visual_block_with_virtualedit() CheckScreendump -- cgit