From d02d0705b396b0deed399af01a370e8c9de6f7e6 Mon Sep 17 00:00:00 2001
From: "Kim F. Storm" <storm@cua.dk>
Date: Tue, 15 Feb 2005 23:04:45 +0000
Subject: [PATCH] (BUFFER_POS_REACHED_P): Return true if pos reached and at end
 of display vector.

---
 src/xdisp.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/xdisp.c b/src/xdisp.c
index c7f446def55..c0489aa5ecb 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -5819,11 +5819,14 @@ move_it_in_display_line_to (it, to_charpos, to_x, op)
   saved_glyph_row = it->glyph_row;
   it->glyph_row = NULL;
 
-#define BUFFER_POS_REACHED_P()			\
-  ((op & MOVE_TO_POS) != 0			\
-   && BUFFERP (it->object)			\
-   && IT_CHARPOS (*it) >= to_charpos		\
-   && it->method == next_element_from_buffer)
+#define BUFFER_POS_REACHED_P()					\
+  ((op & MOVE_TO_POS) != 0					\
+   && BUFFERP (it->object)					\
+   && IT_CHARPOS (*it) >= to_charpos				\
+   && (it->method == next_element_from_buffer ||		\
+       (it->method == next_element_from_display_vector &&	\
+	it->dpvec + it->current.dpvec_index + 1 >= it->dpend)))
+
 
   while (1)
     {
-- 
2.39.5