Fix bug #4426 with buffer_posn_from_coords when header line is present.
authorEli Zaretskii <eliz@gnu.org>
Sat, 8 Oct 2011 10:58:50 +0000 (12:58 +0200)
committerEli Zaretskii <eliz@gnu.org>
Sat, 8 Oct 2011 10:58:50 +0000 (12:58 +0200)
 dispnew.c (buffer_posn_from_coords): Account it.vpos for a possible
 presence of header-line.

src/ChangeLog
src/dispnew.c

index 38c452f..edfecaa 100644 (file)
@@ -1,3 +1,8 @@
+2011-10-08  Eli Zaretskii  <eliz@gnu.org>
+
+       * dispnew.c (buffer_posn_from_coords): Account for a possible
+       presence of header-line.  (Bug#4426)
+
 2011-10-07  Stefan Monnier  <monnier@iro.umontreal.ca>
 
        * buffer.c (syms_of_buffer) <enable-multibyte-characters>: Don't
index 51b17fc..46d1917 100644 (file)
@@ -5261,6 +5261,10 @@ buffer_posn_from_coords (struct window *w, int *x, int *y, struct display_pos *p
   CHARPOS (startp) = min (ZV, max (BEGV, CHARPOS (startp)));
   BYTEPOS (startp) = min (ZV_BYTE, max (BEGV_BYTE, BYTEPOS (startp)));
   start_display (&it, w, startp);
+  /* start_display takes into account the header-line row, but IT's
+     vpos still counts from the glyph row that includes the window's
+     start position.  Adjust for a possible header-line row.  */
+  it.vpos += WINDOW_WANTS_HEADER_LINE_P (w) ? 1 : 0;
 
   x0 = *x;