From 63dbfd33c1d47400c62775842b5b750ee69e2383 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sat, 23 Mar 2019 17:41:59 +0100 Subject: 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) --- src/if_py_both.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/if_py_both.h') diff --git a/src/if_py_both.h b/src/if_py_both.h index 8d11488d3..b27f93e49 100644 --- a/src/if_py_both.h +++ b/src/if_py_both.h @@ -4392,7 +4392,10 @@ SetBufferLine(buf_T *buf, PyInt n, PyObject *line, PyInt *len_change) 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". */ -- cgit v1.2.1