changeset 9762:567e3670acc3

(fast_find_position): Special case if POS is end of buffer.
author Richard M. Stallman <rms@gnu.org>
date Tue, 01 Nov 1994 00:07:34 +0000
parents 1a75c4fe2ece
children 296cd41d2601
files src/xterm.c
diffstat 1 files changed, 17 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/xterm.c	Mon Oct 31 21:50:17 1994 +0000
+++ b/src/xterm.c	Tue Nov 01 00:07:34 1994 +0000
@@ -2018,6 +2018,7 @@
   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 @@
       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 @@
 	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;