aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/xdisp.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/xdisp.c b/src/xdisp.c
index 30a32896aba..6572d14d934 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -3545,7 +3545,7 @@ init_iterator (struct it *it, struct window *w,
3545 3545
3546 The corresponding function 'get_medium_narrowing_zv' (and 3546 The corresponding function 'get_medium_narrowing_zv' (and
3547 'medium_narrowing_zv' field in 'struct it') is not used to set the 3547 'medium_narrowing_zv' field in 'struct it') is not used to set the
3548 end limit of a the restriction, which is again unnecessary, but to 3548 end limit of the restriction, which is again unnecessary, but to
3549 determine, in 'reseat', whether the iterator has moved far enough 3549 determine, in 'reseat', whether the iterator has moved far enough
3550 from its original position, and whether the start position of the 3550 from its original position, and whether the start position of the
3551 restriction must be computed anew. 3551 restriction must be computed anew.
@@ -3613,10 +3613,15 @@ get_medium_narrowing_zv (struct window *w, ptrdiff_t pos)
3613 return min ((pos / len + 1) * len, ZV); 3613 return min ((pos / len + 1) * len, ZV);
3614} 3614}
3615 3615
3616/* Find the position of the last BOL before POS, unless it is too far
3617 away. The buffer portion in which the search occurs is gradually
3618 enlarged: [POS-500..POS], [POS-5500..POS-500],
3619 [POS-55500..POS-5500], and finally [POS-555500..POS-55500]. Return
3620 BEGV-1 if no BOL was found in [POS-555500..POS]. */
3616static ptrdiff_t 3621static ptrdiff_t
3617get_nearby_bol_pos (ptrdiff_t pos) 3622get_nearby_bol_pos (ptrdiff_t pos)
3618{ 3623{
3619 ptrdiff_t start, pos_bytepos, cur, next, found, bol = BEGV - 1; 3624 ptrdiff_t start, pos_bytepos, cur, next, found, bol = BEGV - 1, init_pos = pos;
3620 int dist; 3625 int dist;
3621 for (dist = 500; dist <= 500000; dist *= 10) 3626 for (dist = 500; dist <= 500000; dist *= 10)
3622 { 3627 {
@@ -3633,10 +3638,11 @@ get_nearby_bol_pos (ptrdiff_t pos)
3633 break; 3638 break;
3634 } 3639 }
3635 if (bol >= BEGV || start == BEGV) 3640 if (bol >= BEGV || start == BEGV)
3636 return bol; 3641 break;
3637 else 3642 else
3638 pos = pos - dist < BEGV ? BEGV : pos - dist; 3643 pos = pos - dist < BEGV ? BEGV : pos - dist;
3639 } 3644 }
3645 eassert (bol <= init_pos);
3640 return bol; 3646 return bol;
3641} 3647}
3642 3648