I notice that using python to set cursor position, the behaviour is the
same as 'virtualedit' is set to 'onemore'---if the column pos is too
large, it will be put after the end of line. The patch will check 've'
option and decide where to put the cursor if the column pos is too
large.
--
Best regards,
lilydjwg
Linux Vim Python 我的博客
http://lilydjwg.is-programmer.com/
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
diff --git a/src/if_py_both.h b/src/if_py_both.h
index 07eedb5..43412e1 100644
--- a/src/if_py_both.h
+++ b/src/if_py_both.h
@@ -535,6 +535,9 @@ WindowSetattr(PyObject *self, char *name, PyObject *val)
long lnum;
long col;
long len;
+#ifdef FEAT_VIRTUALEDIT
+ long coladd = 0;
+#endif
if (!PyArg_Parse(val, "(ll)", &lnum, &col))
return -1;
@@ -551,13 +554,40 @@ WindowSetattr(PyObject *self, char *name, PyObject *val)
/* When column is out of range silently correct it. */
len = (long)STRLEN(ml_get_buf(this->win->w_buffer, lnum, FALSE));
- if (col > len)
- col = len;
+#ifdef FEAT_VIRTUALEDIT
+ if (ve_flags & VE_ALL)
+ {
+ if (col > len)
+ {
+ coladd = col - len;
+ if (coladd > W_WIDTH(this->win) - 1)
+ {
+ coladd = W_WIDTH(this->win) - 1;
+ }
+ col = len;
+ }
+ }
+ else
+#endif
+ if (State & INSERT
+#ifdef FEAT_VIRTUALEDIT
+ || ve_flags & VE_ONEMORE
+#endif
+ )
+ {
+ if (col > len)
+ col = len;
+ }
+ else
+ {
+ if (col > len - 1)
+ col = len - 1;
+ }
this->win->w_cursor.lnum = lnum;
this->win->w_cursor.col = col;
#ifdef FEAT_VIRTUALEDIT
- this->win->w_cursor.coladd = 0;
+ this->win->w_cursor.coladd = coladd;
#endif
update_screen(VALID);