aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/xdisp.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/xdisp.c b/src/xdisp.c
index 4bc68ce58fc..b8f2a4cb8bb 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -5873,6 +5873,15 @@ next_element_from_composition (it)
5873 Moving an iterator without producing glyphs 5873 Moving an iterator without producing glyphs
5874 ***********************************************************************/ 5874 ***********************************************************************/
5875 5875
5876/* Check if iterator is at a position corresponding to a valid buffer
5877 position after some move_it_ call. */
5878
5879#define IT_POS_VALID_AFTER_MOVE_P(it) \
5880 ((it)->method == GET_FROM_STRING \
5881 ? IT_STRING_CHARPOS (*it) == 0 \
5882 : 1)
5883
5884
5876/* Move iterator IT to a specified buffer or X position within one 5885/* Move iterator IT to a specified buffer or X position within one
5877 line on the display without producing glyphs. 5886 line on the display without producing glyphs.
5878 5887
@@ -6386,7 +6395,7 @@ move_it_vertically_backward (it, dy)
6386 move_it_to (&it2, start_pos, -1, -1, it2.vpos + 1, 6395 move_it_to (&it2, start_pos, -1, -1, it2.vpos + 1,
6387 MOVE_TO_POS | MOVE_TO_VPOS); 6396 MOVE_TO_POS | MOVE_TO_VPOS);
6388 } 6397 }
6389 while (it2.method != GET_FROM_BUFFER); 6398 while (!IT_POS_VALID_AFTER_MOVE_P (&it2));
6390 xassert (IT_CHARPOS (*it) >= BEGV); 6399 xassert (IT_CHARPOS (*it) >= BEGV);
6391 it3 = it2; 6400 it3 = it2;
6392 6401
@@ -6586,7 +6595,7 @@ move_it_by_lines (it, dvpos, need_y_p)
6586 else if (dvpos > 0) 6595 else if (dvpos > 0)
6587 { 6596 {
6588 move_it_to (it, -1, -1, -1, it->vpos + dvpos, MOVE_TO_VPOS); 6597 move_it_to (it, -1, -1, -1, it->vpos + dvpos, MOVE_TO_VPOS);
6589 if (it->method != GET_FROM_BUFFER) 6598 if (!IT_POS_VALID_AFTER_MOVE_P (it))
6590 move_it_to (it, IT_CHARPOS (*it) + 1, -1, -1, -1, MOVE_TO_POS); 6599 move_it_to (it, IT_CHARPOS (*it) + 1, -1, -1, -1, MOVE_TO_POS);
6591 } 6600 }
6592 else 6601 else
@@ -6608,13 +6617,13 @@ move_it_by_lines (it, dvpos, need_y_p)
6608 reseat (it, it->current.pos, 1); 6617 reseat (it, it->current.pos, 1);
6609 6618
6610 /* Move further back if we end up in a string or an image. */ 6619 /* Move further back if we end up in a string or an image. */
6611 while (it->method != GET_FROM_BUFFER) 6620 while (!IT_POS_VALID_AFTER_MOVE_P (it))
6612 { 6621 {
6613 /* First try to move to start of display line. */ 6622 /* First try to move to start of display line. */
6614 dvpos += it->vpos; 6623 dvpos += it->vpos;
6615 move_it_vertically_backward (it, 0); 6624 move_it_vertically_backward (it, 0);
6616 dvpos -= it->vpos; 6625 dvpos -= it->vpos;
6617 if (it->method == GET_FROM_BUFFER) 6626 if (IT_POS_VALID_AFTER_MOVE_P (it))
6618 break; 6627 break;
6619 /* If start of line is still in string or image, 6628 /* If start of line is still in string or image,
6620 move further back. */ 6629 move further back. */