mirror of
https://github.com/neovim/neovim.git
synced 2025-09-19 09:48:19 +00:00
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.
This commit is contained in:
@@ -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;
|
||||
|
Reference in New Issue
Block a user