]> granicus.if.org Git - vim/commitdiff
updated for version 7.3.239 v7.3.239
authorBram Moolenaar <Bram@vim.org>
Thu, 7 Jul 2011 13:08:58 +0000 (15:08 +0200)
committerBram Moolenaar <Bram@vim.org>
Thu, 7 Jul 2011 13:08:58 +0000 (15:08 +0200)
Problem:    Python corrects the cursor column without taking 'virtualedit'
            into account. (lilydjwg)
Solution:   Call check_cursor_col_win().

src/if_py_both.h
src/mbyte.c
src/misc2.c
src/normal.c
src/proto/mbyte.pro
src/proto/misc2.pro
src/version.c

index 07eedb5f314be33b686dad8a74d72e6029ebb449..c7870bc10b3200c9bb1bd449b842fbe803026eae 100644 (file)
@@ -534,7 +534,6 @@ WindowSetattr(PyObject *self, char *name, PyObject *val)
     {
        long lnum;
        long col;
-       long len;
 
        if (!PyArg_Parse(val, "(ll)", &lnum, &col))
            return -1;
@@ -549,18 +548,15 @@ WindowSetattr(PyObject *self, char *name, PyObject *val)
        if (VimErrorCheck())
            return -1;
 
-       /* 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;
-
        this->win->w_cursor.lnum = lnum;
        this->win->w_cursor.col = col;
 #ifdef FEAT_VIRTUALEDIT
        this->win->w_cursor.coladd = 0;
 #endif
-       update_screen(VALID);
+       /* When column is out of range silently correct it. */
+       check_cursor_col_win(this->win);
 
+       update_screen(VALID);
        return 0;
     }
     else if (strcmp(name, "height") == 0)
index ce0c8975eebc3400878b3627ccb3720e9c54208d..6e0dbf65491d906adb2cfa6e8278247a1e23a80e 100644 (file)
@@ -3563,7 +3563,7 @@ dbcs_screen_tail_off(base, p)
     void
 mb_adjust_cursor()
 {
-    mb_adjustpos(&curwin->w_cursor);
+    mb_adjustpos(curbuf, &curwin->w_cursor);
 }
 
 /*
@@ -3571,7 +3571,8 @@ mb_adjust_cursor()
  * If it points to a tail byte it's moved backwards to the head byte.
  */
     void
-mb_adjustpos(lp)
+mb_adjustpos(buf, lp)
+    buf_T      *buf;
     pos_T      *lp;
 {
     char_u     *p;
@@ -3582,7 +3583,7 @@ mb_adjustpos(lp)
 #endif
            )
     {
-       p = ml_get(lp->lnum);
+       p = ml_get_buf(buf, lp->lnum, FALSE);
        lp->col -= (*mb_head_off)(p, p + lp->col);
 #ifdef FEAT_VIRTUALEDIT
        /* Reset "coladd" when the cursor would be on the right half of a
index c6207ff042a11ab86c8c5d5e875934de0433fc77..9479a53c20d8f85dd663da953a02a615edd89fae 100644 (file)
@@ -333,7 +333,7 @@ coladvance2(pos, addspaces, finetune, wcol)
 #ifdef FEAT_MBYTE
     /* prevent from moving onto a trail byte */
     if (has_mbyte)
-       mb_adjustpos(pos);
+       mb_adjustpos(curbuf, pos);
 #endif
 
     if (col < wcol)
@@ -543,17 +543,27 @@ check_cursor_lnum()
  */
     void
 check_cursor_col()
+{
+    check_cursor_col_win(curwin);
+}
+
+/*
+ * Make sure win->w_cursor.col is valid.
+ */
+    void
+check_cursor_col_win(win)
+    win_T *win;
 {
     colnr_T len;
 #ifdef FEAT_VIRTUALEDIT
-    colnr_T oldcol = curwin->w_cursor.col;
-    colnr_T oldcoladd = curwin->w_cursor.col + curwin->w_cursor.coladd;
+    colnr_T oldcol = win->w_cursor.col;
+    colnr_T oldcoladd = win->w_cursor.col + win->w_cursor.coladd;
 #endif
 
-    len = (colnr_T)STRLEN(ml_get_curline());
+    len = (colnr_T)STRLEN(ml_get_buf(win->w_buffer, win->w_cursor.lnum, FALSE));
     if (len == 0)
-       curwin->w_cursor.col = 0;
-    else if (curwin->w_cursor.col >= len)
+       win->w_cursor.col = 0;
+    else if (win->w_cursor.col >= len)
     {
        /* Allow cursor past end-of-line when:
         * - in Insert mode or restarting Insert mode
@@ -567,33 +577,33 @@ check_cursor_col()
                || (ve_flags & VE_ONEMORE)
 #endif
                || virtual_active())
-           curwin->w_cursor.col = len;
+           win->w_cursor.col = len;
        else
        {
-           curwin->w_cursor.col = len - 1;
+           win->w_cursor.col = len - 1;
 #ifdef FEAT_MBYTE
-           /* prevent cursor from moving on the trail byte */
+           /* Move the cursor to the head byte. */
            if (has_mbyte)
-               mb_adjust_cursor();
+               mb_adjustpos(win->w_buffer, &win->w_cursor);
 #endif
        }
     }
-    else if (curwin->w_cursor.col < 0)
-       curwin->w_cursor.col = 0;
+    else if (win->w_cursor.col < 0)
+       win->w_cursor.col = 0;
 
 #ifdef FEAT_VIRTUALEDIT
     /* If virtual editing is on, we can leave the cursor on the old position,
      * only we must set it to virtual.  But don't do it when at the end of the
      * line. */
     if (oldcol == MAXCOL)
-       curwin->w_cursor.coladd = 0;
+       win->w_cursor.coladd = 0;
     else if (ve_flags == VE_ALL)
     {
-       if (oldcoladd > curwin->w_cursor.col)
-           curwin->w_cursor.coladd = oldcoladd - curwin->w_cursor.col;
+       if (oldcoladd > win->w_cursor.col)
+           win->w_cursor.coladd = oldcoladd - win->w_cursor.col;
        else
            /* avoid weird number when there is a miscalculation or overflow */
-           curwin->w_cursor.coladd = 0;
+           win->w_cursor.coladd = 0;
     }
 #endif
 }
index bd6f1f239cb76c99b2359874835143a96c9192e9..522480fc4af97d51ad53c303bafe641bf3299916 100644 (file)
@@ -8774,7 +8774,7 @@ unadjust_for_sel()
        {
            --pp->col;
 #ifdef FEAT_MBYTE
-           mb_adjustpos(pp);
+           mb_adjustpos(curbuf, pp);
 #endif
        }
        else if (pp->lnum > 1)
index 9519a19371f2c0771f10020a1cf121f3cfe4f809..88496ccf06dc6e20010773f58b99f6a8e2091924 100644 (file)
@@ -56,7 +56,7 @@ void utf_find_illegal __ARGS((void));
 int utf_valid_string __ARGS((char_u *s, char_u *end));
 int dbcs_screen_tail_off __ARGS((char_u *base, char_u *p));
 void mb_adjust_cursor __ARGS((void));
-void mb_adjustpos __ARGS((pos_T *lp));
+void mb_adjustpos __ARGS((buf_T *buf, pos_T *lp));
 char_u *mb_prevptr __ARGS((char_u *line, char_u *p));
 int mb_charlen __ARGS((char_u *str));
 int mb_charlen_len __ARGS((char_u *str, int len));
index 720d263fd67c331d364b9262fd34958eeaa9ddae..a22ba7f0ae784b4ac5c12a5d08e894e98a601d72 100644 (file)
@@ -14,6 +14,7 @@ int decl __ARGS((pos_T *lp));
 linenr_T get_cursor_rel_lnum __ARGS((win_T *wp, linenr_T lnum));
 void check_cursor_lnum __ARGS((void));
 void check_cursor_col __ARGS((void));
+void check_cursor_col_win __ARGS((win_T *win));
 void check_cursor __ARGS((void));
 void adjust_cursor_col __ARGS((void));
 int leftcol_changed __ARGS((void));
index 92612ad3acf7486e57dff03d720745b66d616c97..8af816c08022fe140a656ab72949c40e4f9c74de 100644 (file)
@@ -709,6 +709,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    239,
 /**/
     238,
 /**/