From 342d18b91ec176c5e3aa6d32d439d01e6ac88ee6 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 12 Aug 2022 21:16:28 +0800 Subject: refactor: remove some unused includes (#19740) Mostly avoids including eval.h, ex_cmds2.h and ex_docmd.h in other headers. --- src/nvim/api/vimscript.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/nvim/api/vimscript.c') diff --git a/src/nvim/api/vimscript.c b/src/nvim/api/vimscript.c index 478e146781..3b25e3aa38 100644 --- a/src/nvim/api/vimscript.c +++ b/src/nvim/api/vimscript.c @@ -14,8 +14,9 @@ #include "nvim/eval.h" #include "nvim/eval/typval.h" #include "nvim/eval/userfunc.h" -#include "nvim/ex_cmds2.h" +#include "nvim/ex_docmd.h" #include "nvim/ops.h" +#include "nvim/runtime.h" #include "nvim/strings.h" #include "nvim/vim.h" #include "nvim/viml/parser/expressions.h" -- cgit From 03fddfd92887bbac920d80cd9e04f28f32843f5d Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 16 Aug 2022 17:30:39 +0800 Subject: fix(api): nvim_exec and nvim_cmd restore msg_col when capturing output (#19789) This matches the code in execute_common(), preventing messages after the API call from being printed at the wrong column. --- src/nvim/api/vimscript.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/nvim/api/vimscript.c') diff --git a/src/nvim/api/vimscript.c b/src/nvim/api/vimscript.c index 3b25e3aa38..a28bfd2ab9 100644 --- a/src/nvim/api/vimscript.c +++ b/src/nvim/api/vimscript.c @@ -49,6 +49,7 @@ String nvim_exec(uint64_t channel_id, String src, Boolean output, Error *err) { const int save_msg_silent = msg_silent; garray_T *const save_capture_ga = capture_ga; + const int save_msg_col = msg_col; garray_T capture_local; if (output) { ga_init(&capture_local, 1, 80); @@ -58,6 +59,7 @@ String nvim_exec(uint64_t channel_id, String src, Boolean output, Error *err) try_start(); if (output) { msg_silent++; + msg_col = 0; // prevent leading spaces } const sctx_T save_current_sctx = api_set_sctx(channel_id); @@ -66,6 +68,8 @@ String nvim_exec(uint64_t channel_id, String src, Boolean output, Error *err) if (output) { capture_ga = save_capture_ga; msg_silent = save_msg_silent; + // Put msg_col back where it was, since nothing should have been written. + msg_col = save_msg_col; } current_sctx = save_current_sctx; -- cgit