emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] emacs-26 fe06fcc: Avoid infinite hscrolling loops when lin


From: Eli Zaretskii
Subject: [Emacs-diffs] emacs-26 fe06fcc: Avoid infinite hscrolling loops when line numbers are displayed
Date: Tue, 28 Aug 2018 07:12:15 -0400 (EDT)

branch: emacs-26
commit fe06fcc5955731b1373aa74a586da04f5c2c11f7
Author: Eli Zaretskii <address@hidden>
Commit: Eli Zaretskii <address@hidden>

    Avoid infinite hscrolling loops when line numbers are displayed
    
    * src/xdisp.c (maybe_produce_line_number): Don't produce line
    numbers if we don't have enough screen estate.  (Bug#32351)
---
 src/xdisp.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/src/xdisp.c b/src/xdisp.c
index 9a82953..eccefa4 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -21166,8 +21166,12 @@ maybe_produce_line_number (struct it *it)
      an L2R paragraph.  */
   tem_it.bidi_it.resolved_level = 2;
 
+  /* We must leave space for 2 glyphs for continuation and truncation,
+     and at least one glyph for buffer text.  */
+  int width_limit =
+    tem_it.last_visible_x - tem_it.first_visible_x
+    - 3 * FRAME_COLUMN_WIDTH (it->f);
   /* Produce glyphs for the line number in a scratch glyph_row.  */
-  int n_glyphs_before;
   for (const char *p = lnum_buf; *p; p++)
     {
       /* For continuation lines and lines after ZV, instead of a line
@@ -21191,18 +21195,18 @@ maybe_produce_line_number (struct it *it)
       else
        tem_it.c = tem_it.char_to_display = *p;
       tem_it.len = 1;
-      n_glyphs_before = scratch_glyph_row.used[TEXT_AREA];
       /* Make sure these glyphs will have a "position" of -1.  */
       SET_TEXT_POS (tem_it.position, -1, -1);
       PRODUCE_GLYPHS (&tem_it);
 
-      /* Stop producing glyphs if we don't have enough space on
-        this line.  FIXME: should we refrain from producing the
-        line number at all in that case?  */
-      if (tem_it.current_x > tem_it.last_visible_x)
+      /* Stop producing glyphs, and refrain from producing the line
+        number, if we don't have enough space on this line.  */
+      if (tem_it.current_x >= width_limit)
        {
-         scratch_glyph_row.used[TEXT_AREA] = n_glyphs_before;
-         break;
+         it->lnum_width = 0;
+         it->lnum_pixel_width = 0;
+         bidi_unshelve_cache (itdata, false);
+         return;
        }
     }
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]