aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/eval/funcs.c
diff options
context:
space:
mode:
authorSean Dewar <seandewar@users.noreply.github.com>2021-04-14 20:13:22 +0100
committerSean Dewar <seandewar@users.noreply.github.com>2021-04-21 14:55:04 +0100
commit65f35e0c7db700c25d9de9a3c8637f720c07583a (patch)
tree57ac945230ad1271c337d38256147e5f2e67bd33 /src/nvim/eval/funcs.c
parent805eb81ccdc6a7000926e458b6e0dd59df16a112 (diff)
downloadrneovim-65f35e0c7db700c25d9de9a3c8637f720c07583a.tar.gz
rneovim-65f35e0c7db700c25d9de9a3c8637f720c07583a.tar.bz2
rneovim-65f35e0c7db700c25d9de9a3c8637f720c07583a.zip
vim-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 vim/vim#6851) https://github.com/vim/vim/commit/077cc7aa0e0c431e97795612374fe17fe7c88803 Updated prompt_getprompt() doc to https://github.com/vim/vim/commit/cb80aa2d53e56d3aba3b3c439fb467f29a750c5e and removed mention of method syntax usage (not supported by Nvim).
Diffstat (limited to 'src/nvim/eval/funcs.c')
-rw-r--r--src/nvim/eval/funcs.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c
index 206f76ba8e..6d328953f6 100644
--- a/src/nvim/eval/funcs.c
+++ b/src/nvim/eval/funcs.c
@@ -6491,6 +6491,26 @@ static void f_prompt_setinterrupt(typval_T *argvars,
buf->b_prompt_interrupt= interrupt_callback;
}
+/// "prompt_getprompt({buffer})" function
+void f_prompt_getprompt(typval_T *argvars, typval_T *rettv, FunPtr fptr)
+ FUNC_ATTR_NONNULL_ALL
+{
+ // 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_T *const 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
static void f_prompt_setprompt(typval_T *argvars,
typval_T *rettv, FunPtr fptr)