diff src/if_py_both.h @ 16080:bf8cf5c3b784 v8.1.1045

patch 8.1.1045: E315 ml_get error when using Python and hidden buffer commit https://github.com/vim/vim/commit/63dbfd33c1d47400c62775842b5b750ee69e2383 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Mar 23 17:41:59 2019 +0100 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer Problem: E315 ml_get error when using Python and hidden buffer. Solution: Make sure the cursor position is valid. (Ben Jackson, closes #4153, closes #4154)
author Bram Moolenaar <Bram@vim.org>
date Sat, 23 Mar 2019 17:45:05 +0100
parents 89486329d9e6
children ab815ed87969
line wrap: on
line diff
--- a/src/if_py_both.h
+++ b/src/if_py_both.h
@@ -4392,7 +4392,10 @@ SetBufferLine(buf_T *buf, PyInt n, PyObj
 	    RAISE_DELETE_LINE_FAIL;
 	else
 	{
-	    if (buf == curbuf)
+	    if (buf == curbuf && (save_curwin != NULL
+					   || save_curbuf.br_buf == NULL))
+		// Using an existing window for the buffer, adjust the cursor
+		// position.
 		py_fix_cursor((linenr_T)n, (linenr_T)n + 1, (linenr_T)-1);
 	    if (save_curbuf.br_buf == NULL)
 		/* Only adjust marks if we managed to switch to a window that
@@ -4642,7 +4645,10 @@ SetBufferLineList(
 						  (long)MAXLNUM, (long)extra);
 	changed_lines((linenr_T)lo, 0, (linenr_T)hi, (long)extra);
 
-	if (buf == curbuf)
+	if (buf == curbuf && (save_curwin != NULL
+					   || save_curbuf.br_buf == NULL))
+	    // Using an existing window for the buffer, adjust the cursor
+	    // position.
 	    py_fix_cursor((linenr_T)lo, (linenr_T)hi, (linenr_T)extra);
 
 	/* END of region without "return". */