Skip to content

Commit 7d3b647

Browse files
kuuotechrisbra
authored andcommitted
patch 9.1.1880: Allocation error with complete_info()
Problem: Allocation error with complete_info() (after v9.1.1876) Solution: Make sure length is positive (kuuote) closes: #18640 Signed-off-by: kuuote <znmxodq1@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
1 parent bd9155e commit 7d3b647

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

src/insexpand.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4235,7 +4235,7 @@ get_complete_info(list_T *what_list, dict_T *retdict)
42354235
int len = compl_ins_end_col - curwin->w_cursor.col;
42364236

42374237
ret = dict_add_string_len(retdict, "preinserted_text",
4238-
(len > 0) ? line + curwin->w_cursor.col : (char_u *)"", len);
4238+
(len > 0) ? line + curwin->w_cursor.col : (char_u *)"", (len > 0) ? len : 0);
42394239
}
42404240

42414241
if (ret == OK && (what_flag & (CI_WHAT_ITEMS | CI_WHAT_SELECTED

src/testdir/test_ins_complete.vim

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,10 @@ func Test_completefunc_info()
571571
new
572572
set completeopt=menuone
573573
set completefunc=CompleteTest
574+
" Can be called outside of ins-completion
575+
call feedkeys("i\<C-X>\<C-U>\<C-Y>\<C-R>\<C-R>=string(complete_info())\<CR>\<ESC>", "tx")
576+
call assert_equal("matched{'preinserted_text': '', 'pum_visible': 0, 'mode': '', 'selected': -1, 'items': []}", getline(1))
577+
%d
574578
call feedkeys("i\<C-X>\<C-U>\<C-R>\<C-R>=string(complete_info())\<CR>\<ESC>", "tx")
575579
call assert_equal("matched{'preinserted_text': '', 'pum_visible': 1, 'mode': 'function', 'selected': 0, 'items': [{'word': 'matched', 'menu': '', 'user_data': '', 'info': '', 'kind': '', 'abbr': ''}]}", getline(1))
576580
%d

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,8 @@ static char *(features[]) =
729729

730730
static int included_patches[] =
731731
{ /* Add new patch number below this line */
732+
/**/
733+
1880,
732734
/**/
733735
1879,
734736
/**/

0 commit comments

Comments
 (0)