all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: npostavs@users.sourceforge.net
To: Eli Zaretskii <eliz@gnu.org>
Cc: alexanderm@web.de, 25792@debbugs.gnu.org
Subject: bug#25792: 26.0.50; Scroll-margin working incorrectly when scrolling down if show-trailing-whitespace is t
Date: Mon, 20 Feb 2017 13:46:02 -0500	[thread overview]
Message-ID: <87lgt0itud.fsf@users.sourceforge.net> (raw)
In-Reply-To: <83zihgoi4t.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 20 Feb 2017 20:02:26 +0200")

[-- Attachment #1: Type: text/plain, Size: 902 bytes --]

tags 25792 patch
quit

Eli Zaretskii <eliz@gnu.org> writes:

>> From: npostavs@users.sourceforge.net
>> Cc: 25792@debbugs.gnu.org,  alexanderm@web.de
>> Date: Mon, 20 Feb 2017 12:42:58 -0500
>> 
>> The difference seems to be that try_window returns -1 in the case where
>> we correctly stay out of the margin, but 1 in the case where we cross
>> into it.  I tried adding a partial_line_height call, but it's not giving
>> the right answer.  The move_it_to (&it, ZV, -1, it.last_visible_y, -1,
>> MOVE_TO_POS | MOVE_TO_Y) call doesn't stop at last_visible_y, it goes to
>> the end of buffer, so the returned partial height is a very large number
>> (approx 6500 in my test).
>
> Probably because it.current_y is already beyond it.last_visible_y, due
> to the loop before the call:

Ah, right.

> Does it work to call start_display again, before the call to
> partial_line_height?

Yes, here's a patch:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 2124 bytes --]

From f3f948057ae78a551a2f83d89f7918623bed3e6e Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@gmail.com>
Date: Mon, 20 Feb 2017 13:34:39 -0500
Subject: [PATCH v1] Fix scrolling with partial line corner case (Bug#25792)

* src/xdisp.c (try_window): Take partial line height into account when
comparing cursor position against scroll margin.
---
 src/xdisp.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/xdisp.c b/src/xdisp.c
index e59934d2d5..6c94147844 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -17376,21 +17376,27 @@ try_window (Lisp_Object window, struct text_pos pos, int flags)
 	return 0;
     }
 
+  /* Save the character position of 'it' before we call
+     'start_display' again.  */
+  ptrdiff_t it_charpos = IT_CHARPOS (it);
+
   /* Don't let the cursor end in the scroll margins.  */
   if ((flags & TRY_WINDOW_CHECK_MARGINS)
       && !MINI_WINDOW_P (w))
     {
       int this_scroll_margin = window_scroll_margin (w, MARGIN_IN_PIXELS);
+      start_display (&it, w, pos);
 
       if ((w->cursor.y >= 0	/* not vscrolled */
 	   && w->cursor.y < this_scroll_margin
 	   && CHARPOS (pos) > BEGV
-	   && IT_CHARPOS (it) < ZV)
+           && it_charpos < ZV)
 	  /* rms: considering make_cursor_line_fully_visible_p here
 	     seems to give wrong results.  We don't want to recenter
 	     when the last line is partly visible, we want to allow
 	     that case to be handled in the usual way.  */
-	  || w->cursor.y > it.last_visible_y - this_scroll_margin - 1)
+          || w->cursor.y > (it.last_visible_y - partial_line_height (&it)
+                            - this_scroll_margin - 1))
 	{
 	  w->cursor.vpos = -1;
 	  clear_glyph_matrix (w->desired_matrix);
@@ -17399,7 +17405,7 @@ try_window (Lisp_Object window, struct text_pos pos, int flags)
     }
 
   /* If bottom moved off end of frame, change mode line percentage.  */
-  if (w->window_end_pos <= 0 && Z != IT_CHARPOS (it))
+  if (w->window_end_pos <= 0 && Z != it_charpos)
     w->update_mode_line = true;
 
   /* Set window_end_pos to the offset of the last character displayed
-- 
2.11.1


  reply	other threads:[~2017-02-20 18:46 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-19 15:34 bug#25792: 26.0.50; Scroll-margin working incorrectly when scrolling down if show-trailing-whitespace is t Alexander Miller
2017-02-19 16:59 ` npostavs
2017-02-19 17:20   ` Eli Zaretskii
2017-02-19 20:56     ` Eli Zaretskii
2017-02-20 17:42       ` npostavs
2017-02-20 18:02         ` Eli Zaretskii
2017-02-20 18:46           ` npostavs [this message]
2017-02-20 19:36             ` Eli Zaretskii
2017-02-25  4:37               ` npostavs

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87lgt0itud.fsf@users.sourceforge.net \
    --to=npostavs@users.sourceforge.net \
    --cc=25792@debbugs.gnu.org \
    --cc=alexanderm@web.de \
    --cc=eliz@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.