X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/55d38fc89f5aeb9a73c9a8e13914fbb8a9a6a1af..49f7c5ad68cb9c542cfddee7bed17d207f1fc394:/src/xdisp.c diff --git a/src/xdisp.c b/src/xdisp.c index 2d0d67784c..efd5f54fa3 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -1321,6 +1321,11 @@ pos_visible_p (struct window *w, ptrdiff_t charpos, int *x, int *y, if (CHARPOS (top) > ZV) SET_TEXT_POS (top, BEGV, BEGV_BYTE); + /* If the top of the window is after CHARPOS, the latter is surely + not visible. */ + if (charpos >= 0 && CHARPOS (top) > charpos) + return visible_p; + /* Compute exact mode line heights. */ if (WINDOW_WANTS_MODELINE_P (w)) w->mode_line_height @@ -2232,7 +2237,7 @@ get_phys_cursor_geometry (struct window *w, struct glyph_row *row, ascent = row->ascent; if (row->ascent < glyph->ascent) { - y =- glyph->ascent - row->ascent; + y -= glyph->ascent - row->ascent; ascent = glyph->ascent; } @@ -8609,8 +8614,7 @@ move_it_in_display_line_to (struct it *it, && it->dpvec + it->current.dpvec_index + 1 >= it->dpend))) /* If there's a line-/wrap-prefix, handle it. */ - if (it->hpos == 0 && it->method == GET_FROM_BUFFER - && it->current_y < it->last_visible_y) + if (it->hpos == 0 && it->method == GET_FROM_BUFFER) handle_line_prefix (it); if (IT_CHARPOS (*it) < CHARPOS (this_line_min_pos)) @@ -15513,12 +15517,14 @@ try_scrolling (Lisp_Object window, bool just_this_one_p, The new window start will be computed, based on W's width, starting from the start of the continued line. It is the start of the - screen line with the minimum distance from the old start W->start. */ + screen line with the minimum distance from the old start W->start, + which is still before point (otherwise point will definitely not + be visible in the window). */ static bool compute_window_start_on_continuation_line (struct window *w) { - struct text_pos pos, start_pos; + struct text_pos pos, start_pos, pos_before_pt; bool window_start_changed_p = false; SET_TEXT_POS_FROM_MARKER (start_pos, w->start); @@ -15546,10 +15552,14 @@ compute_window_start_on_continuation_line (struct window *w) reseat_at_previous_visible_line_start (&it); /* If the line start is "too far" away from the window start, - say it takes too much time to compute a new window start. */ - if (CHARPOS (start_pos) - IT_CHARPOS (it) - /* PXW: Do we need upper bounds here? */ - < WINDOW_TOTAL_LINES (w) * WINDOW_TOTAL_COLS (w)) + say it takes too much time to compute a new window start. + Also, give up if the line start is after point, as in that + case point will not be visible with any window start we + compute. */ + if (IT_CHARPOS (it) <= PT + || (CHARPOS (start_pos) - IT_CHARPOS (it) + /* PXW: Do we need upper bounds here? */ + < WINDOW_TOTAL_LINES (w) * WINDOW_TOTAL_COLS (w))) { int min_distance, distance; @@ -15559,12 +15569,14 @@ compute_window_start_on_continuation_line (struct window *w) decreased, the new window start will be < the old start. So, we're looking for the display line start with the minimum distance from the old window start. */ - pos = it.current.pos; + pos_before_pt = pos = it.current.pos; min_distance = INFINITY; while ((distance = eabs (CHARPOS (start_pos) - IT_CHARPOS (it))), distance < min_distance) { min_distance = distance; + if (CHARPOS (pos) <= PT) + pos_before_pt = pos; pos = it.current.pos; if (it.line_wrap == WORD_WRAP) { @@ -15587,6 +15599,13 @@ compute_window_start_on_continuation_line (struct window *w) move_it_by_lines (&it, 1); } + /* It makes very little sense to make the new window start + after point, as point won't be visible. If that's what + the loop above finds, fall back on the candidate before + or at point that is closest to the old window start. */ + if (CHARPOS (pos) > PT) + pos = pos_before_pt; + /* Set the window start there. */ SET_MARKER_FROM_TEXT_POS (w->start, pos); window_start_changed_p = true; @@ -27350,8 +27369,8 @@ x_produce_glyphs (struct it *it) eassume (0 < glyph_len); /* See Bug#8512. */ do - c = COMPOSITION_GLYPH (cmp, --glyph_len); - while (c == '\t' && 0 < glyph_len); + c = COMPOSITION_GLYPH (cmp, glyph_len - 1); + while (c == '\t' && 0 < --glyph_len); bool right_padded = glyph_len < cmp->glyph_len; for (i = 0; i < glyph_len; i++)