diff src/normal.c @ 9:4102fb4ea781 v7.0002

updated for version 7.0002
author vimboss
date Sun, 20 Jun 2004 12:51:53 +0000
parents 3fc0f57ecb91
children 4424b47a0797
line wrap: on
line diff
--- a/src/normal.c
+++ b/src/normal.c
@@ -5186,7 +5186,23 @@ nv_scroll(cap)
 	if (cap->count1 - 1 >= curwin->w_cursor.lnum)
 	    curwin->w_cursor.lnum = 1;
 	else
-	    curwin->w_cursor.lnum -= cap->count1 - 1;
+	{
+#ifdef FEAT_FOLDING
+	    if (hasAnyFolding(curwin))
+	    {
+		/* Count a fold for one screen line. */
+		for (n = cap->count1 - 1; n > 0
+			    && curwin->w_cursor.lnum > curwin->w_topline; --n)
+		{
+		    (void)hasFolding(curwin->w_cursor.lnum,
+						&curwin->w_cursor.lnum, NULL);
+		    --curwin->w_cursor.lnum;
+		}
+	    }
+	    else
+#endif
+		curwin->w_cursor.lnum -= cap->count1 - 1;
+	}
     }
     else
     {
@@ -5222,8 +5238,23 @@ nv_scroll(cap)
 	    if (n > 0 && used > curwin->w_height)
 		--n;
 	}
-	else
+	else /* (cap->cmdchar == 'H') */
+	{
 	    n = cap->count1 - 1;
+#ifdef FEAT_FOLDING
+	    if (hasAnyFolding(curwin))
+	    {
+		/* Count a fold for one screen line. */
+		lnum = curwin->w_topline;
+		while (n-- > 0 && lnum < curwin->w_botline - 1)
+		{
+		    hasFolding(lnum, NULL, &lnum);
+		    ++lnum;
+		}
+		n = lnum - curwin->w_topline;
+	    }
+#endif
+	}
 	curwin->w_cursor.lnum = curwin->w_topline + n;
 	if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count)
 	    curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count;