aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2018-08-28 14:11:12 +0300
committerEli Zaretskii2018-08-28 14:11:12 +0300
commitfe06fcc5955731b1373aa74a586da04f5c2c11f7 (patch)
tree570a23ff35a8074eb536aed35a9b42451ac73983
parent63e59c8ca51ced6c4d5951281cb21288da32ced3 (diff)
downloademacs-fe06fcc5955731b1373aa74a586da04f5c2c11f7.tar.gz
emacs-fe06fcc5955731b1373aa74a586da04f5c2c11f7.zip
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)
-rw-r--r--src/xdisp.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/xdisp.c b/src/xdisp.c
index 9a82953952f..eccefa41cf3 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -21166,8 +21166,12 @@ maybe_produce_line_number (struct it *it)
21166 an L2R paragraph. */ 21166 an L2R paragraph. */
21167 tem_it.bidi_it.resolved_level = 2; 21167 tem_it.bidi_it.resolved_level = 2;
21168 21168
21169 /* We must leave space for 2 glyphs for continuation and truncation,
21170 and at least one glyph for buffer text. */
21171 int width_limit =
21172 tem_it.last_visible_x - tem_it.first_visible_x
21173 - 3 * FRAME_COLUMN_WIDTH (it->f);
21169 /* Produce glyphs for the line number in a scratch glyph_row. */ 21174 /* Produce glyphs for the line number in a scratch glyph_row. */
21170 int n_glyphs_before;
21171 for (const char *p = lnum_buf; *p; p++) 21175 for (const char *p = lnum_buf; *p; p++)
21172 { 21176 {
21173 /* For continuation lines and lines after ZV, instead of a line 21177 /* For continuation lines and lines after ZV, instead of a line
@@ -21191,18 +21195,18 @@ maybe_produce_line_number (struct it *it)
21191 else 21195 else
21192 tem_it.c = tem_it.char_to_display = *p; 21196 tem_it.c = tem_it.char_to_display = *p;
21193 tem_it.len = 1; 21197 tem_it.len = 1;
21194 n_glyphs_before = scratch_glyph_row.used[TEXT_AREA];
21195 /* Make sure these glyphs will have a "position" of -1. */ 21198 /* Make sure these glyphs will have a "position" of -1. */
21196 SET_TEXT_POS (tem_it.position, -1, -1); 21199 SET_TEXT_POS (tem_it.position, -1, -1);
21197 PRODUCE_GLYPHS (&tem_it); 21200 PRODUCE_GLYPHS (&tem_it);
21198 21201
21199 /* Stop producing glyphs if we don't have enough space on 21202 /* Stop producing glyphs, and refrain from producing the line
21200 this line. FIXME: should we refrain from producing the 21203 number, if we don't have enough space on this line. */
21201 line number at all in that case? */ 21204 if (tem_it.current_x >= width_limit)
21202 if (tem_it.current_x > tem_it.last_visible_x)
21203 { 21205 {
21204 scratch_glyph_row.used[TEXT_AREA] = n_glyphs_before; 21206 it->lnum_width = 0;
21205 break; 21207 it->lnum_pixel_width = 0;
21208 bidi_unshelve_cache (itdata, false);
21209 return;
21206 } 21210 }
21207 } 21211 }
21208 21212