summaryrefslogtreecommitdiff
path: root/src/if_py_both.h
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-03-23 17:41:59 +0100
committerBram Moolenaar <Bram@vim.org>2019-03-23 17:41:59 +0100
commit63dbfd33c1d47400c62775842b5b750ee69e2383 (patch)
tree37c30be324222ed4a7134224f6878af9c7001786 /src/if_py_both.h
parentc3e92c161d6394d126a334011526c02e8c3f655f (diff)
downloadvim-git-63dbfd33c1d47400c62775842b5b750ee69e2383.tar.gz
patch 8.1.1045: E315 ml_get error when using Python and hidden bufferv8.1.1045
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)
Diffstat (limited to 'src/if_py_both.h')
-rw-r--r--src/if_py_both.h10
1 files changed, 8 insertions, 2 deletions
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". */