summaryrefslogtreecommitdiff
blob: 24a1167b6cf7ac435ee1cb74c3c573a7f8a6b9f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
--- a/ansi.c
+++ b/ansi.c
@@ -2502,13 +2502,13 @@
     return;
   if (n > 0)
     {
+      if (ye - ys + 1 < n)
+	n = ye - ys + 1;
       if (n > 256)
 	{
 	  MScrollV(p, n - 256, ys, ye, bce);
 	  n = 256;
 	}
-      if (ye - ys + 1 < n)
-	n = ye - ys + 1;
 #ifdef COPY_PASTE
       if (compacthist)
 	{
@@ -2562,15 +2562,14 @@
     }
   else
     {
+      n = -n;
+      if (ye - ys + 1 < n)
+	n = ye - ys + 1;
       if (n < -256)
 	{
 	  MScrollV(p, n + 256, ys, ye, bce);
 	  n = -256;
 	}
-      n = -n;
-      if (ye - ys + 1 < n)
-	n = ye - ys + 1;
-
       ml = p->w_mlines + ye;
       /* Clear lines */
       for (i = ye; i > ye - n; i--, ml--)