mirror of
https://github.com/vim/vim.git
synced 2025-11-13 22:54:27 -05:00
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>
This commit is contained in:
committed by
Christian Brabandt
parent
bd9155ebb6
commit
7d3b647f88
@@ -4235,7 +4235,7 @@ get_complete_info(list_T *what_list, dict_T *retdict)
|
|||||||
int len = compl_ins_end_col - curwin->w_cursor.col;
|
int len = compl_ins_end_col - curwin->w_cursor.col;
|
||||||
|
|
||||||
ret = dict_add_string_len(retdict, "preinserted_text",
|
ret = dict_add_string_len(retdict, "preinserted_text",
|
||||||
(len > 0) ? line + curwin->w_cursor.col : (char_u *)"", len);
|
(len > 0) ? line + curwin->w_cursor.col : (char_u *)"", (len > 0) ? len : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret == OK && (what_flag & (CI_WHAT_ITEMS | CI_WHAT_SELECTED
|
if (ret == OK && (what_flag & (CI_WHAT_ITEMS | CI_WHAT_SELECTED
|
||||||
|
|||||||
@@ -571,6 +571,10 @@ func Test_completefunc_info()
|
|||||||
new
|
new
|
||||||
set completeopt=menuone
|
set completeopt=menuone
|
||||||
set completefunc=CompleteTest
|
set completefunc=CompleteTest
|
||||||
|
" Can be called outside of ins-completion
|
||||||
|
call feedkeys("i\<C-X>\<C-U>\<C-Y>\<C-R>\<C-R>=string(complete_info())\<CR>\<ESC>", "tx")
|
||||||
|
call assert_equal("matched{'preinserted_text': '', 'pum_visible': 0, 'mode': '', 'selected': -1, 'items': []}", getline(1))
|
||||||
|
%d
|
||||||
call feedkeys("i\<C-X>\<C-U>\<C-R>\<C-R>=string(complete_info())\<CR>\<ESC>", "tx")
|
call feedkeys("i\<C-X>\<C-U>\<C-R>\<C-R>=string(complete_info())\<CR>\<ESC>", "tx")
|
||||||
call assert_equal("matched{'preinserted_text': '', 'pum_visible': 1, 'mode': 'function', 'selected': 0, 'items': [{'word': 'matched', 'menu': '', 'user_data': '', 'info': '', 'kind': '', 'abbr': ''}]}", getline(1))
|
call assert_equal("matched{'preinserted_text': '', 'pum_visible': 1, 'mode': 'function', 'selected': 0, 'items': [{'word': 'matched', 'menu': '', 'user_data': '', 'info': '', 'kind': '', 'abbr': ''}]}", getline(1))
|
||||||
%d
|
%d
|
||||||
|
|||||||
@@ -729,6 +729,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1880,
|
||||||
/**/
|
/**/
|
||||||
1879,
|
1879,
|
||||||
/**/
|
/**/
|
||||||
|
|||||||
Reference in New Issue
Block a user