patch 9.1.0787: cursor position changed when using hidden terminal
Problem: cursor position changed when using hidden terminal
and BufFilePost autocommand (Mizuno Jan Yuta)
Solution: Save and restore cursor position
fixes: #15854
closes: #15876
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/terminal.c b/src/terminal.c
index 073f8dd..f61a54f 100644
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -446,6 +446,7 @@
buf_T *newbuf;
int vertical = opt->jo_vertical || (cmdmod.cmod_split & WSP_VERT);
jobopt_T orig_opt; // only partly filled
+ pos_T save_cursor;
if (check_restricted() || check_secure())
return NULL;
@@ -518,6 +519,7 @@
old_curbuf = curbuf;
--curbuf->b_nwindows;
curbuf = buf;
+ save_cursor = curwin->w_cursor;
curwin->w_buffer = buf;
++curbuf->b_nwindows;
}
@@ -763,6 +765,7 @@
--curbuf->b_nwindows;
curbuf = old_curbuf;
curwin->w_buffer = curbuf;
+ curwin->w_cursor = save_cursor;
++curbuf->b_nwindows;
}
else if (vgetc_busy