diff options
| author | Noam Postavsky | 2017-02-20 13:34:39 -0500 |
|---|---|---|
| committer | Noam Postavsky | 2017-02-24 23:15:40 -0500 |
| commit | f0e7f39e0b4026a3d613416ad8ffc84e6b74242b (patch) | |
| tree | de043d57f09d116a7fa101c246c7fbefdb71f79c /src | |
| parent | e52287ca3e974ed9f658315288060f638081abb0 (diff) | |
| download | emacs-f0e7f39e0b4026a3d613416ad8ffc84e6b74242b.tar.gz emacs-f0e7f39e0b4026a3d613416ad8ffc84e6b74242b.zip | |
Fix scrolling with partial line corner case (Bug#25792)
Also fix up the scrolling tests so that they don't make so many
assumptions about the current window configuration.
* src/xdisp.c (try_window): Take partial line height into account when
comparing cursor position against scroll margin.
* test/manual/scroll-tests.el (scroll-tests-with-buffer-window): Add
HEIGHT argument, to allow setting up window with exact height and
partial line.
(scroll-tests-display-buffer-with-height): New display-buffer action
function.
(scroll-tests-scroll-margin-over-max):
(scroll-tests--scroll-margin-whole-window): Pass HEIGHT to
`scroll-tests--scroll-margin-whole-window'.
(scroll-tests-conservative-show-trailing-whitespace): New test.
(scroll-tests-scroll-margin-negative): Fix line counting.
(scroll-tests--point-in-middle-of-window-p): Set window height
properly.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xdisp.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/xdisp.c b/src/xdisp.c index b0ff627c70e..b0644882bdc 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -17380,21 +17380,27 @@ try_window (Lisp_Object window, struct text_pos pos, int flags) | |||
| 17380 | return 0; | 17380 | return 0; |
| 17381 | } | 17381 | } |
| 17382 | 17382 | ||
| 17383 | /* Save the character position of 'it' before we call | ||
| 17384 | 'start_display' again. */ | ||
| 17385 | ptrdiff_t it_charpos = IT_CHARPOS (it); | ||
| 17386 | |||
| 17383 | /* Don't let the cursor end in the scroll margins. */ | 17387 | /* Don't let the cursor end in the scroll margins. */ |
| 17384 | if ((flags & TRY_WINDOW_CHECK_MARGINS) | 17388 | if ((flags & TRY_WINDOW_CHECK_MARGINS) |
| 17385 | && !MINI_WINDOW_P (w)) | 17389 | && !MINI_WINDOW_P (w)) |
| 17386 | { | 17390 | { |
| 17387 | int this_scroll_margin = window_scroll_margin (w, MARGIN_IN_PIXELS); | 17391 | int this_scroll_margin = window_scroll_margin (w, MARGIN_IN_PIXELS); |
| 17392 | start_display (&it, w, pos); | ||
| 17388 | 17393 | ||
| 17389 | if ((w->cursor.y >= 0 /* not vscrolled */ | 17394 | if ((w->cursor.y >= 0 /* not vscrolled */ |
| 17390 | && w->cursor.y < this_scroll_margin | 17395 | && w->cursor.y < this_scroll_margin |
| 17391 | && CHARPOS (pos) > BEGV | 17396 | && CHARPOS (pos) > BEGV |
| 17392 | && IT_CHARPOS (it) < ZV) | 17397 | && it_charpos < ZV) |
| 17393 | /* rms: considering make_cursor_line_fully_visible_p here | 17398 | /* rms: considering make_cursor_line_fully_visible_p here |
| 17394 | seems to give wrong results. We don't want to recenter | 17399 | seems to give wrong results. We don't want to recenter |
| 17395 | when the last line is partly visible, we want to allow | 17400 | when the last line is partly visible, we want to allow |
| 17396 | that case to be handled in the usual way. */ | 17401 | that case to be handled in the usual way. */ |
| 17397 | || w->cursor.y > it.last_visible_y - this_scroll_margin - 1) | 17402 | || w->cursor.y > (it.last_visible_y - partial_line_height (&it) |
| 17403 | - this_scroll_margin - 1)) | ||
| 17398 | { | 17404 | { |
| 17399 | w->cursor.vpos = -1; | 17405 | w->cursor.vpos = -1; |
| 17400 | clear_glyph_matrix (w->desired_matrix); | 17406 | clear_glyph_matrix (w->desired_matrix); |
| @@ -17403,7 +17409,7 @@ try_window (Lisp_Object window, struct text_pos pos, int flags) | |||
| 17403 | } | 17409 | } |
| 17404 | 17410 | ||
| 17405 | /* If bottom moved off end of frame, change mode line percentage. */ | 17411 | /* If bottom moved off end of frame, change mode line percentage. */ |
| 17406 | if (w->window_end_pos <= 0 && Z != IT_CHARPOS (it)) | 17412 | if (w->window_end_pos <= 0 && Z != it_charpos) |
| 17407 | w->update_mode_line = true; | 17413 | w->update_mode_line = true; |
| 17408 | 17414 | ||
| 17409 | /* Set window_end_pos to the offset of the last character displayed | 17415 | /* Set window_end_pos to the offset of the last character displayed |