0
0
mirror of https://github.com/vim/vim.git synced 2025-11-15 23:14:06 -05:00

patch 8.2.1588: cannot read back the prompt of a prompt buffer

Problem:    Cannot read back the prompt of a prompt buffer.
Solution:   Add prompt_getprompt(). (Ben Jackson, closes #6851)
This commit is contained in:
Bram Moolenaar
2020-09-04 16:35:35 +02:00
parent eadee486c7
commit 077cc7aa0e
10 changed files with 97 additions and 6 deletions

View File

@@ -6368,6 +6368,29 @@ f_prompt_setinterrupt(typval_T *argvars, typval_T *rettv UNUSED)
set_callback(&buf->b_prompt_interrupt, &callback);
}
/*
* "prompt_getprompt({buffer})" function
*/
void
f_prompt_getprompt(typval_T *argvars, typval_T *rettv)
{
buf_T *buf;
// return an empty string by default, e.g. it's not a prompt buffer
rettv->v_type = VAR_STRING;
rettv->vval.v_string = NULL;
buf = tv_get_buf_from_arg(&argvars[0]);
if (buf == NULL)
return;
if (!bt_prompt(buf))
return;
rettv->vval.v_string = vim_strsave(buf_prompt_text(buf));
}
/*
* "prompt_setprompt({buffer}, {text})" function
*/