]> git.eshelyaron.com Git - emacs.git/commitdiff
* src/xdisp.c (redisplay_window): Use BEG rather than hard coding 1
authorStefan Monnier <monnier@iro.umontreal.ca>
Tue, 2 Aug 2022 14:38:53 +0000 (10:38 -0400)
committerStefan Monnier <monnier@iro.umontreal.ca>
Tue, 2 Aug 2022 17:06:51 +0000 (13:06 -0400)
src/marker.c
src/xdisp.c

index 3c8e628762e88d4423451778ebfc9bddc937c1aa..9727586f4245b431d1813a1b80e45ba3b9701494 100644 (file)
@@ -214,11 +214,12 @@ buf_charpos_to_bytepos (struct buffer *b, ptrdiff_t charpos)
      We have one known above and one known below.
      Scan, counting characters, from whichever one is closer.  */
 
+  eassert (best_below <= charpos && charpos <= best_above);
   if (charpos - best_below < best_above - charpos)
     {
       bool record = charpos - best_below > 5000;
 
-      while (best_below != charpos)
+      while (best_below < charpos)
        {
          best_below++;
          best_below_byte += buf_next_char_len (b, best_below_byte);
@@ -243,7 +244,7 @@ buf_charpos_to_bytepos (struct buffer *b, ptrdiff_t charpos)
     {
       bool record = best_above - charpos > 5000;
 
-      while (best_above != charpos)
+      while (best_above > charpos)
        {
          best_above--;
          best_above_byte -= buf_prev_char_len (b, best_above_byte);
index 65d9221a159bdaaeda82f025491dbf0d8829564c..2bedf1c78471308ee46d00ce0a3ab86266160017 100644 (file)
@@ -19449,7 +19449,7 @@ redisplay_window (Lisp_Object window, bool just_this_one_p)
     {
       ptrdiff_t cur, next, found, max = 0, threshold;
       threshold = XFIXNUM (Vlong_line_threshold);
-      for (cur = 1; cur < Z; cur = next)
+      for (cur = BEG; cur < Z; cur = next)
        {
          next = find_newline1 (cur, CHAR_TO_BYTE (cur), 0, -1, 1,
                                &found, NULL, true);