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.
44db8213d3
This commit is contained in:
Christian Clason
2022-01-26 16:47:39 +01:00
parent e9247b0d5d
commit 540264306b
2 changed files with 8 additions and 1 deletions

View File

@@ -2801,7 +2801,7 @@ static void yank_copy_line(yankreg_T *reg, struct block_def *bd, size_t y_idx,
if (exclude_trailing_space) { if (exclude_trailing_space) {
int s = bd->textlen + bd->endspaces; 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; s = s - utf_head_off(bd->textstart, bd->textstart + s - 1) - 1;
pnew--; pnew--;
} }

View File

@@ -1103,6 +1103,13 @@ func Test_visual_put_blockedit_zy_and_zp()
bw! bw!
endfunc endfunc
func Test_visual_block_yank_zy()
new
" this was reading before the start of the line
exe "norm o\<C-T>\<Esc>\<C-V>zy"
bwipe!
endfunc
func Test_visual_block_with_virtualedit() func Test_visual_block_with_virtualedit()
CheckScreendump CheckScreendump