From 4765d4e0599704b6251fc39346118656341d39e9 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sat, 12 Jul 2025 00:17:45 -0400 Subject: [PATCH] vim-patch:8.1.1584: the evalfunc.c file is getting too big Problem: The evalfunc.c file is getting too big. Solution: Move channel and job related functions to channel.c. https://github.com/vim/vim/commit/0a1f56fcfe31be929e9cd8c3d81a984c960e4180 --- N/A patches below: vim-patch:8.1.0770: inconsistent use of ELAPSED_FUNC Problem: Inconsistent use of ELAPSED_FUNC. Solution: Consistently use ELAPSED_FUNC. Also turn ELAPSED_TYPE into a typedef. (Ozaki Kiichi, closes vim/vim#3815) https://github.com/vim/vim/commit/1ac56c2d11da5ffa44db23e1fd0c533d02ab2f66 vim-patch:8.1.0914: code related to findfile() is spread out Problem: Code related to findfile() is spread out. Solution: Put findfile() related code into a new source file. (Yegappan Lakshmanan, closes vim/vim#3934) https://github.com/vim/vim/commit/5fd0f5052f9a312bb4cfe7b4176b1211d45127ee vim-patch:8.1.1004: function "luaV_setref()" not covered with tests Problem: Function "luaV_setref()" not covered with tests. Solution: Add a test. (Dominique Pelle, closes vim/vim#4089) https://github.com/vim/vim/commit/e165f63598b58bfdac0168583aa1ef75fbf7be6d vim-patch:8.1.1551: warning for shadowing popup_dragwin Problem: Warning for shadowing popup_dragwin. (Dominique Pelle) Solution: Add missing change. https://github.com/vim/vim/commit/6c17543b5634ccccedfbffa4993e9fbd4a990067 vim-patch:8.1.1629: terminal function help is in the wrong file Problem: Terminal function help is in the wrong file. Solution: Move the function details to terminal.txt. https://github.com/vim/vim/commit/6bf2c6264b5ebbe4981751840c5a8b69da08e744 vim-patch:8.1.1641: garbage collection may run at a wrong moment Problem: Garbage collection may run at a wrong moment. (Trygve Aaberge) Solution: Postpone garbage collection while parsing messages. (closes vim/vim#4620) https://github.com/vim/vim/commit/6cc7e21412487ff8bd531c73ac9325f5ba2409a9 vim-patch:8.1.1703: breaking out of loop by checking window pointer insufficient Problem: Breaking out of loop by checking window pointer is insufficient. Solution: Check the window ID and the buffer number. (closes vim/vim#4683) https://github.com/vim/vim/commit/61386408063a2300d7d7f42c5156f66f6252fb54 vim-patch:8.1.1802: missing change to call_callback() Problem: Missing change to call_callback(). Solution: Add missing change. https://github.com/vim/vim/commit/b2129068a55261bea1e293a6a1ce8491a03e7de6 vim-patch:8.1.1853: timers test is still flaky Problem: Timers test is still flaky. Solution: Compute the time to sleep more accurately. https://github.com/vim/vim/commit/52953194afccbcb6c2fd013b7a9e2cfbf202b9d0 --- Seems N/A now because of commit 09370eae7756b07bb8f1f116b690b22aec7ec563 --- vim-patch:8.1.2200: crash when memory allocation fails Problem: Crash when memory allocation fails. Solution: Check for NULL curwin and curbuf. (Christian Brabandt, closes vim/vim#4839) https://github.com/vim/vim/commit/1cac70953d3c012453ea85b1308a8b1f94359c26 vim-patch:8.2.3922: cannot build with dynamic Ruby 3.1 Problem: Cannot build with dynamic Ruby 3.1. Solution: Add "_EXTRA" variables for CI. Add missing functions. (Ozaki Kiichi, closes vim/vim#9420) https://github.com/vim/vim/commit/8bb3fe4d4dcd27c02e903f6772fdc8fe2e9eba70 vim-patch:9.0.0546: supporting Ruby 1.8 makes code complicated Problem: Supporting Ruby 1.8 makes code complicated. Solution: Drop Ruby 1.8 support, it is ancient. (Ken Takata, closes vim/vim#11195) https://github.com/vim/vim/commit/236ccbf6f8a671a45b773de4b34558ecfdf9ac02 vim-patch:9.0.0928: using Ruby LDFLAGS may cause build problems Problem: Using Ruby LDFLAGS may cause build problems. Solution: Do not add Ruby LDFLAGS to Vim's LDFLAGS. (Zdenek Dohnal, closes vim/vim#11592) https://github.com/vim/vim/commit/1d822afaf66a84fab71c84521fd92db11d2c8925 vim-patch:9.1.1382: if_ruby: unused compiler warnings from ruby internals Problem: if_ruby: unused compiler warnings from ruby internals Solution: disable -Wunused-parameter for if_ruby internal code (Philip H.) closes: vim/vim#17297 https://github.com/vim/vim/commit/411730e277c408f89c82ae7dbb1ebfa71ec0f4e5 Co-authored-by: Bram Moolenaar --- src/nvim/channel.c | 64 +++++++++++++++++++++++++++++++++++++++++++ src/nvim/eval/funcs.c | 62 ----------------------------------------- 2 files changed, 64 insertions(+), 62 deletions(-) diff --git a/src/nvim/channel.c b/src/nvim/channel.c index 899add944e7..6a3d5394e23 100644 --- a/src/nvim/channel.c +++ b/src/nvim/channel.c @@ -17,6 +17,7 @@ #include "nvim/errors.h" #include "nvim/eval.h" #include "nvim/eval/encode.h" +#include "nvim/eval/funcs.h" #include "nvim/eval/typval.h" #include "nvim/event/loop.h" #include "nvim/event/multiqueue.h" @@ -24,6 +25,7 @@ #include "nvim/event/rstream.h" #include "nvim/event/socket.h" #include "nvim/event/wstream.h" +#include "nvim/ex_cmds.h" #include "nvim/garray.h" #include "nvim/gettext_defs.h" #include "nvim/globals.h" @@ -1001,3 +1003,65 @@ Array channel_all_info(Arena *arena) } return ret; } + +/// "prompt_setcallback({buffer}, {callback})" function +void f_prompt_setcallback(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) +{ + Callback prompt_callback = { .type = kCallbackNone }; + + if (check_secure()) { + return; + } + buf_T *buf = tv_get_buf(&argvars[0], false); + if (buf == NULL) { + return; + } + + if (argvars[1].v_type != VAR_STRING || *argvars[1].vval.v_string != NUL) { + if (!callback_from_typval(&prompt_callback, &argvars[1])) { + return; + } + } + + callback_free(&buf->b_prompt_callback); + buf->b_prompt_callback = prompt_callback; +} + +/// "prompt_setinterrupt({buffer}, {callback})" function +void f_prompt_setinterrupt(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) +{ + Callback interrupt_callback = { .type = kCallbackNone }; + + if (check_secure()) { + return; + } + buf_T *buf = tv_get_buf(&argvars[0], false); + if (buf == NULL) { + return; + } + + if (argvars[1].v_type != VAR_STRING || *argvars[1].vval.v_string != NUL) { + if (!callback_from_typval(&interrupt_callback, &argvars[1])) { + return; + } + } + + callback_free(&buf->b_prompt_interrupt); + buf->b_prompt_interrupt = interrupt_callback; +} + +/// "prompt_setprompt({buffer}, {text})" function +void f_prompt_setprompt(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) +{ + if (check_secure()) { + return; + } + buf_T *buf = tv_get_buf(&argvars[0], false); + if (buf == NULL) { + return; + } + + const char *text = tv_get_string(&argvars[1]); + xfree(buf->b_prompt_text); + buf->b_prompt_text = xstrdup(text); +} diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index 738aad695b0..f72148d0ba9 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -5241,52 +5241,6 @@ static void f_printf(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) } } -/// "prompt_setcallback({buffer}, {callback})" function -static void f_prompt_setcallback(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) -{ - Callback prompt_callback = { .type = kCallbackNone }; - - if (check_secure()) { - return; - } - buf_T *buf = tv_get_buf(&argvars[0], false); - if (buf == NULL) { - return; - } - - if (argvars[1].v_type != VAR_STRING || *argvars[1].vval.v_string != NUL) { - if (!callback_from_typval(&prompt_callback, &argvars[1])) { - return; - } - } - - callback_free(&buf->b_prompt_callback); - buf->b_prompt_callback = prompt_callback; -} - -/// "prompt_setinterrupt({buffer}, {callback})" function -static void f_prompt_setinterrupt(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) -{ - Callback interrupt_callback = { .type = kCallbackNone }; - - if (check_secure()) { - return; - } - buf_T *buf = tv_get_buf(&argvars[0], false); - if (buf == NULL) { - return; - } - - if (argvars[1].v_type != VAR_STRING || *argvars[1].vval.v_string != NUL) { - if (!callback_from_typval(&interrupt_callback, &argvars[1])) { - return; - } - } - - callback_free(&buf->b_prompt_interrupt); - buf->b_prompt_interrupt = interrupt_callback; -} - /// "prompt_getprompt({buffer})" function static void f_prompt_getprompt(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) FUNC_ATTR_NONNULL_ALL @@ -5307,22 +5261,6 @@ static void f_prompt_getprompt(typval_T *argvars, typval_T *rettv, EvalFuncData rettv->vval.v_string = xstrdup(buf_prompt_text(buf)); } -/// "prompt_setprompt({buffer}, {text})" function -static void f_prompt_setprompt(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) -{ - if (check_secure()) { - return; - } - buf_T *buf = tv_get_buf(&argvars[0], false); - if (buf == NULL) { - return; - } - - const char *text = tv_get_string(&argvars[1]); - xfree(buf->b_prompt_text); - buf->b_prompt_text = xstrdup(text); -} - /// "prompt_getinput({buffer})" function static void f_prompt_getinput(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) FUNC_ATTR_NONNULL_ALL