From 16c6dfb4f16bd399c70eade799ee5621614f7e83 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Mon, 6 Jan 2020 21:49:24 +0200 Subject: [PATCH] Avoid assertion violations in very small-height windows * src/xdisp.c (try_cursor_movement, redisplay_window) (row_containing_pos): Skip tab-line glyph rows in addition to header-line rows, when working on the top-most glyph row of a window. This avoids assertion violations in set_cursor_from_row. (Bug#38966) --- src/xdisp.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/src/xdisp.c b/src/xdisp.c index 3d286cb22fb..f3a297a7020 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -16244,8 +16244,8 @@ set_cursor_from_row (struct window *w, struct glyph_row *row, bool string_from_text_prop = false; /* Don't even try doing anything if called for a mode-line or - header-line row, since the rest of the code isn't prepared to - deal with such calamities. */ + header-line or tab-line row, since the rest of the code isn't + prepared to deal with such calamities. */ eassert (!row->mode_line_p); if (row->mode_line_p) return false; @@ -17504,6 +17504,9 @@ try_cursor_movement (Lisp_Object window, struct text_pos startp, else { row = MATRIX_ROW (w->current_matrix, w->last_cursor_vpos); + /* Skip the tab-line and header-line rows, if any. */ + if (row->tab_line_p) + ++row; if (row->mode_line_p) ++row; if (!row->enabled_p) @@ -17576,6 +17579,9 @@ try_cursor_movement (Lisp_Object window, struct text_pos startp, || row->mode_line_p) { row = w->current_matrix->rows; + /* Skip the tab-line and header-line rows, if any. */ + if (row->tab_line_p) + ++row; if (row->mode_line_p) ++row; } @@ -17640,8 +17646,9 @@ try_cursor_movement (Lisp_Object window, struct text_pos startp, ; else if (rc != CURSOR_MOVEMENT_SUCCESS && MATRIX_ROW_PARTIALLY_VISIBLE_P (w, row) - /* Make sure this isn't a header line by any chance, since - then MATRIX_ROW_PARTIALLY_VISIBLE_P might yield true. */ + /* Make sure this isn't a header line nor a tab-line by + any chance, since then MATRIX_ROW_PARTIALLY_VISIBLE_P + might yield true. */ && !row->mode_line_p && !cursor_row_fully_visible_p (w, true, true, true)) { @@ -18769,11 +18776,14 @@ redisplay_window (Lisp_Object window, bool just_this_one_p) } } /* Finally, fall back on the first row of the window after the - header line (if any). This is slightly better than not - displaying the cursor at all. */ + tab-line and header line (if any). This is slightly better + than not displaying the cursor at all. */ if (!row) { row = matrix->rows; + /* Skip the tab-line and header-line rows, if any. */ + if (row->tab_line_p) + ++row; if (row->mode_line_p) ++row; } @@ -19787,7 +19797,9 @@ row_containing_pos (struct window *w, ptrdiff_t charpos, ptrdiff_t mindif = BUF_ZV (XBUFFER (w->contents)) + 1; int last_y; - /* If we happen to start on a header-line, skip that. */ + /* If we happen to start on a header-line or a tab-line, skip that. */ + if (row->tab_line_p) + ++row; if (row->mode_line_p) ++row; @@ -22380,7 +22392,7 @@ find_row_edges (struct it *it, struct glyph_row *row, if (STRINGP (it->object) /* this is not the first row */ && row > it->w->desired_matrix->rows - /* previous row is not the header line */ + /* previous row is not the header line or tab-line */ && !r1->mode_line_p /* previous row also ends in a newline from a string */ && r1->ends_in_newline_from_string_p) -- 2.39.2