mirror of
https://github.com/vim/vim.git
synced 2025-11-16 23:24:03 -05:00
patch 9.1.1876: pre-inserted text not exposed in cmdcomplete_info()
Problem: pre-inserted text not exposed in complete_info()
Solution: Add the pre-inserted text to the complete_info() Vim script
function (Girish Palya)
closes: #18571
Signed-off-by: Girish Palya <girishji@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Feat: expose preinserted text in complete_info()
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
f17f78c557
commit
ef5bf58d8c
@@ -4186,13 +4186,14 @@ get_complete_info(list_T *what_list, dict_T *retdict)
|
||||
{
|
||||
int ret = OK;
|
||||
listitem_T *item;
|
||||
#define CI_WHAT_MODE 0x01
|
||||
#define CI_WHAT_PUM_VISIBLE 0x02
|
||||
#define CI_WHAT_ITEMS 0x04
|
||||
#define CI_WHAT_SELECTED 0x08
|
||||
#define CI_WHAT_COMPLETED 0x10
|
||||
#define CI_WHAT_MATCHES 0x20
|
||||
#define CI_WHAT_ALL 0xff
|
||||
#define CI_WHAT_MODE 0x01
|
||||
#define CI_WHAT_PUM_VISIBLE 0x02
|
||||
#define CI_WHAT_ITEMS 0x04
|
||||
#define CI_WHAT_SELECTED 0x08
|
||||
#define CI_WHAT_COMPLETED 0x10
|
||||
#define CI_WHAT_MATCHES 0x20
|
||||
#define CI_WHAT_PREINSERTED_TEXT 0x40
|
||||
#define CI_WHAT_ALL 0xff
|
||||
int what_flag;
|
||||
|
||||
if (what_list == NULL)
|
||||
@@ -4215,6 +4216,8 @@ get_complete_info(list_T *what_list, dict_T *retdict)
|
||||
what_flag |= CI_WHAT_SELECTED;
|
||||
else if (STRCMP(what, "completed") == 0)
|
||||
what_flag |= CI_WHAT_COMPLETED;
|
||||
else if (STRCMP(what, "preinserted_text") == 0)
|
||||
what_flag |= CI_WHAT_PREINSERTED_TEXT;
|
||||
else if (STRCMP(what, "matches") == 0)
|
||||
what_flag |= CI_WHAT_MATCHES;
|
||||
}
|
||||
@@ -4226,6 +4229,15 @@ get_complete_info(list_T *what_list, dict_T *retdict)
|
||||
if (ret == OK && (what_flag & CI_WHAT_PUM_VISIBLE))
|
||||
ret = dict_add_number(retdict, "pum_visible", pum_visible());
|
||||
|
||||
if (ret == OK && (what_flag & CI_WHAT_PREINSERTED_TEXT))
|
||||
{
|
||||
char_u *line = ml_get_curline();
|
||||
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);
|
||||
}
|
||||
|
||||
if (ret == OK && (what_flag & (CI_WHAT_ITEMS | CI_WHAT_SELECTED
|
||||
| CI_WHAT_MATCHES | CI_WHAT_COMPLETED)))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user