int len = compl_ins_end_col - curwin->w_cursor.col;
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
new
set completeopt=menuone
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 assert_equal("matched{'preinserted_text': '', 'pum_visible': 1, 'mode': 'function', 'selected': 0, 'items': [{'word': 'matched', 'menu': '', 'user_data': '', 'info': '', 'kind': '', 'abbr': ''}]}", getline(1))
%d