]> granicus.if.org Git - vim/commitdiff
updated for version 7.4.311 v7.4.311
authorBram Moolenaar <Bram@vim.org>
Wed, 28 May 2014 14:47:16 +0000 (16:47 +0200)
committerBram Moolenaar <Bram@vim.org>
Wed, 28 May 2014 14:47:16 +0000 (16:47 +0200)
Problem:    Can't use winrestview to only restore part of the view.
Solution:   Handle missing items in the dict. (Christian Brabandt)

runtime/doc/eval.txt
src/eval.c
src/version.c

index 94cdf2b9db31abb55ef01b54fda30e061073691f..09a081703576c3d307383735a10b264740be9abb 100644 (file)
@@ -6410,6 +6410,16 @@ winrestcmd()     Returns a sequence of |:resize| commands that should restore
 winrestview({dict})
                Uses the |Dictionary| returned by |winsaveview()| to restore
                the view of the current window.
+               Note: The {dict} does not have to contain all values, that are
+               returned by |winsaveview()|. If values are missing, those
+               settings won't be restored. So you can use: >
+                   :call winrestview({'curswant': 4})
+<
+               This will only set the curswant value (the column the cursor
+               wants to move on vertical movements) of the cursor to column 5
+               (yes, that is 5), while all other settings will remain the
+               same. This is useful, if you set the cursor position manually.
+
                If you have changed the values the result is unpredictable.
                If the window size changed the result won't be the same.
 
@@ -6424,7 +6434,9 @@ winsaveview()     Returns a |Dictionary| that contains information to restore
                not opened when moving around.
                The return value includes:
                        lnum            cursor line number
-                       col             cursor column
+                       col             cursor column (Note: the first column
+                                       zero, as opposed to what getpos()
+                                       returns)
                        coladd          cursor column offset for 'virtualedit'
                        curswant        column for vertical movement
                        topline         first line in the window
index 3d20d177b1605e26d64659918f21ac77337922de..d313c5d03067fcb23020c2786fece3761e7c957e 100644 (file)
@@ -19231,20 +19231,30 @@ f_winrestview(argvars, rettv)
        EMSG(_(e_invarg));
     else
     {
-       curwin->w_cursor.lnum = get_dict_number(dict, (char_u *)"lnum");
-       curwin->w_cursor.col = get_dict_number(dict, (char_u *)"col");
+       if (dict_find(dict, (char_u *)"lnum", -1) != NULL)
+           curwin->w_cursor.lnum = get_dict_number(dict, (char_u *)"lnum");
+       if (dict_find(dict, (char_u *)"col", -1) != NULL)
+           curwin->w_cursor.col = get_dict_number(dict, (char_u *)"col");
 #ifdef FEAT_VIRTUALEDIT
-       curwin->w_cursor.coladd = get_dict_number(dict, (char_u *)"coladd");
+       if (dict_find(dict, (char_u *)"coladd", -1) != NULL)
+           curwin->w_cursor.coladd = get_dict_number(dict, (char_u *)"coladd");
 #endif
-       curwin->w_curswant = get_dict_number(dict, (char_u *)"curswant");
-       curwin->w_set_curswant = FALSE;
+       if (dict_find(dict, (char_u *)"curswant", -1) != NULL)
+       {
+           curwin->w_curswant = get_dict_number(dict, (char_u *)"curswant");
+           curwin->w_set_curswant = FALSE;
+       }
 
-       set_topline(curwin, get_dict_number(dict, (char_u *)"topline"));
+       if (dict_find(dict, (char_u *)"topline", -1) != NULL)
+           set_topline(curwin, get_dict_number(dict, (char_u *)"topline"));
 #ifdef FEAT_DIFF
-       curwin->w_topfill = get_dict_number(dict, (char_u *)"topfill");
+       if (dict_find(dict, (char_u *)"topfill", -1) != NULL)
+           curwin->w_topfill = get_dict_number(dict, (char_u *)"topfill");
 #endif
-       curwin->w_leftcol = get_dict_number(dict, (char_u *)"leftcol");
-       curwin->w_skipcol = get_dict_number(dict, (char_u *)"skipcol");
+       if (dict_find(dict, (char_u *)"leftcol", -1) != NULL)
+           curwin->w_leftcol = get_dict_number(dict, (char_u *)"leftcol");
+       if (dict_find(dict, (char_u *)"skipcol", -1) != NULL)
+           curwin->w_skipcol = get_dict_number(dict, (char_u *)"skipcol");
 
        check_cursor();
        win_new_height(curwin, curwin->w_height);
index d817aa8763fcbf0b13a6de02727c7bc3f86d7a59..85ab6800a99aa39ccf6d1c2eac963b03d2742272 100644 (file)
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    311,
 /**/
     310,
 /**/