]> git.eshelyaron.com Git - emacs.git/commitdiff
(row_containing_pos): Check more carefully
authorRichard M. Stallman <rms@gnu.org>
Mon, 9 Dec 2002 01:56:05 +0000 (01:56 +0000)
committerRichard M. Stallman <rms@gnu.org>
Mon, 9 Dec 2002 01:56:05 +0000 (01:56 +0000)
whether charpos is really in the row before returning it.

src/xdisp.c

index 38df34d7c5399a99df1b957b6255cfe9c59e12a3..bfe9d4f96376a98eb8c7cc61531bc5161d46fa60 100644 (file)
@@ -11509,25 +11509,27 @@ row_containing_pos (w, charpos, start, end, dy)
 
   last_y = window_text_bottom_y (w) - dy;
 
-  while ((end == NULL || row < end)
-        && MATRIX_ROW_BOTTOM_Y (row) < last_y
-        && (MATRIX_ROW_END_CHARPOS (row) < charpos
+  while (1)
+    {
+      /* Give up if we have gone too far.  */
+      if (end && row >= end)
+       return NULL;
+      if (MATRIX_ROW_BOTTOM_Y (row) >= last_y)
+       return NULL;
+
+      /* If it is in this row, return this row.  */
+      if (! (MATRIX_ROW_END_CHARPOS (row) < charpos
             || (MATRIX_ROW_END_CHARPOS (row) == charpos
                 /* The end position of a row equals the start
                    position of the next row.  If CHARPOS is there, we
                    would rather display it in the next line, except
                    when this line ends in ZV.  */
                 && !row->ends_at_zv_p
-                && !MATRIX_ROW_ENDS_IN_MIDDLE_OF_CHAR_P (row))))
-    ++row;
-
-  /* Give up if CHARPOS not found.  */
-  if ((end && row >= end)
-      || charpos < MATRIX_ROW_START_CHARPOS (row)
-      || charpos > MATRIX_ROW_END_CHARPOS (row))
-    row = NULL;
-
-  return row;
+                && !MATRIX_ROW_ENDS_IN_MIDDLE_OF_CHAR_P (row)))
+         && charpos >= MATRIX_ROW_START_CHARPOS (row))
+       return row;
+      ++row;
+    }
 }