vim-patch:8.2.4233: crash when recording and using Select mode

Problem:    Crash when recording and using Select mode.
Solution:   When deleting the last recorded character check there is something
            to delete.
a4bc2dd7cc
This commit is contained in:
Christian Clason 2022-01-28 09:30:52 +01:00 committed by zeertzjq
parent 530c65b17a
commit e691ef338c
2 changed files with 15 additions and 1 deletions

View File

@ -288,8 +288,12 @@ static void add_buff(buffheader_T *const buf, const char *const s, ptrdiff_t sle
/// Only works when it was just added.
static void delete_buff_tail(buffheader_T *buf, int slen)
{
int len = (int)STRLEN(buf->bh_curr->b_str);
int len;
if (buf->bh_curr == NULL || buf->bh_curr->b_str == NULL) {
return; // nothing to delete
}
len = (int)STRLEN(buf->bh_curr->b_str);
if (len >= slen) {
buf->bh_curr->b_str[len - slen] = NUL;
buf->bh_space += (size_t)slen;

View File

@ -511,4 +511,14 @@ func Test_insert_small_delete()
bwipe!
endfunc
func Test_record_in_select_mode()
new
call setline(1, 'text')
sil norm q00
sil norm q
call assert_equal('0ext', getline(1))
bwipe!
endfunc
" vim: shiftwidth=2 sts=2 expandtab