diff options
author | zeertzjq <zeertzjq@outlook.com> | 2025-02-26 13:55:29 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-02-26 05:55:29 +0000 |
commit | f4bb7417b7f52e09bd29750d753b4cbe3b225a82 (patch) | |
tree | 4123b9d7b1ca8f36492002465c558f047c509028 | |
parent | a2b464944a4eb391fe6213304a4df5677845b52c (diff) | |
download | rneovim-f4bb7417b7f52e09bd29750d753b4cbe3b225a82.tar.gz rneovim-f4bb7417b7f52e09bd29750d753b4cbe3b225a82.tar.bz2 rneovim-f4bb7417b7f52e09bd29750d753b4cbe3b225a82.zip |
refactor: remove unnecessary allocation for "run Nvim with -V1" (#32633)
-rw-r--r-- | src/nvim/eval.c | 2 | ||||
-rw-r--r-- | src/nvim/runtime.c | 13 |
2 files changed, 5 insertions, 10 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index bd15b7110f..2b6fefbf82 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -8038,6 +8038,8 @@ void last_set_msg(sctx_T script_ctx) if (script_ctx.sc_lnum > 0) { msg_puts(_(line_msg)); msg_outnum(script_ctx.sc_lnum); + } else if (script_is_lua(script_ctx.sc_sid)) { + msg_puts(_(" (run Nvim with -V1 for more details)")); } if (should_free) { xfree(p); diff --git a/src/nvim/runtime.c b/src/nvim/runtime.c index 8d05169108..9451ca11e2 100644 --- a/src/nvim/runtime.c +++ b/src/nvim/runtime.c @@ -2452,15 +2452,14 @@ char *get_scriptname(sctx_T script_ctx, bool *should_free) case SID_WINLAYOUT: return _("changed window size"); case SID_LUA: - return _("Lua (run Nvim with -V1 for more details)"); + return _("Lua"); case SID_API_CLIENT: snprintf(IObuff, IOSIZE, _("API client (channel id %" PRIu64 ")"), script_ctx.sc_chan); return IObuff; case SID_STR: return _("anonymous :source"); default: { - scriptitem_T *const si = SCRIPT_ITEM(script_ctx.sc_sid); - char *sname = si->sn_name; + char *const sname = SCRIPT_ITEM(script_ctx.sc_sid)->sn_name; if (sname == NULL) { snprintf(IObuff, IOSIZE, _("anonymous :source (script id %d)"), script_ctx.sc_sid); @@ -2468,13 +2467,7 @@ char *get_scriptname(sctx_T script_ctx, bool *should_free) } *should_free = true; - sname = home_replace_save(NULL, sname); - if (si->sn_lua && script_ctx.sc_lnum == 0) { - char *const ret = concat_str(sname, _(" (run Nvim with -V1 for more details)")); - xfree(sname); - return ret; - } - return sname; + return home_replace_save(NULL, sname); } } } |