]> git.eshelyaron.com Git - emacs.git/commitdiff
(fast_find_position): Special case if POS is end of buffer.
authorRichard M. Stallman <rms@gnu.org>
Tue, 1 Nov 1994 00:07:34 +0000 (00:07 +0000)
committerRichard M. Stallman <rms@gnu.org>
Tue, 1 Nov 1994 00:07:34 +0000 (00:07 +0000)
src/xterm.c

index f17efc2c4889bd033d7e7222693b2e0337ee9985..5f560b239fe9d9781f5c48135604a9763e5b3bbe 100644 (file)
@@ -2018,6 +2018,7 @@ fast_find_position (window, pos, columnp, rowp)
   int width = window_internal_width (w);
   int *charstarts;
   int lastcol;
+  int maybe_next_line = 0;
 
   /* Find the right row.  */
   for (i = 0;
@@ -2027,6 +2028,13 @@ fast_find_position (window, pos, columnp, rowp)
       int linestart = FRAME_CURRENT_GLYPHS (f)->charstarts[top + i][left];
       if (linestart > pos)
        break;
+      /* If the position sought is the end of the buffer,
+        don't include the blank lines at the bottom of the window.  */
+      if (linestart == pos && pos == BUF_ZV (XBUFFER (w->buffer)))
+       {
+         maybe_next_line = 1;
+         break;
+       }
       if (linestart > 0)
        row = i;
     }
@@ -2048,6 +2056,15 @@ fast_find_position (window, pos, columnp, rowp)
        lastcol = left + i;
     }
 
+  /* If we're looking for the end of the buffer,
+     and we didn't find it in the line we scanned,
+     use the start of the following line.  */
+  if (maybe_next_line)
+    {
+      row++;
+      i = 0;
+    }
+
   *rowp = row + top;
   *columnp = lastcol;
   return 0;