From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: npostavs@users.sourceforge.net Newsgroups: gmane.emacs.bugs 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 Message-ID: <87lgt0itud.fsf@users.sourceforge.net> References: <93bc26e9-7026-65da-0738-57854568c106@web.de> <8760k6jevp.fsf@users.sourceforge.net> <83h93qp05z.fsf@gnu.org> <83fuj9q4r4.fsf@gnu.org> <87r32siwrh.fsf@users.sourceforge.net> <83zihgoi4t.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1487616312 24347 195.159.176.226 (20 Feb 2017 18:45:12 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 20 Feb 2017 18:45:12 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) Cc: alexanderm@web.de, 25792@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Feb 20 19:45:07 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cfsxO-0005z7-QZ for geb-bug-gnu-emacs@m.gmane.org; Mon, 20 Feb 2017 19:45:07 +0100 Original-Received: from localhost ([::1]:40417 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cfsxU-00058X-OZ for geb-bug-gnu-emacs@m.gmane.org; Mon, 20 Feb 2017 13:45:12 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38788) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cfsxN-00056E-QP for bug-gnu-emacs@gnu.org; Mon, 20 Feb 2017 13:45:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cfsxK-0001BQ-Lf for bug-gnu-emacs@gnu.org; Mon, 20 Feb 2017 13:45:05 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:49580) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cfsxK-0001BL-Iz for bug-gnu-emacs@gnu.org; Mon, 20 Feb 2017 13:45:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cfsxJ-0000wG-O5 for bug-gnu-emacs@gnu.org; Mon, 20 Feb 2017 13:45:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: npostavs@users.sourceforge.net Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 20 Feb 2017 18:45:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 25792 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: confirmed Original-Received: via spool by 25792-submit@debbugs.gnu.org id=B25792.14876162993587 (code B ref 25792); Mon, 20 Feb 2017 18:45:01 +0000 Original-Received: (at 25792) by debbugs.gnu.org; 20 Feb 2017 18:44:59 +0000 Original-Received: from localhost ([127.0.0.1]:47779 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cfsxH-0000vh-AL for submit@debbugs.gnu.org; Mon, 20 Feb 2017 13:44:59 -0500 Original-Received: from mail-it0-f67.google.com ([209.85.214.67]:36325) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cfsxF-0000vO-9K; Mon, 20 Feb 2017 13:44:57 -0500 Original-Received: by mail-it0-f67.google.com with SMTP id w185so5912678ita.3; Mon, 20 Feb 2017 10:44:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=khw/gsGZuyzOSP8QVeDEhWS1cx7qkXvQOKH8PglON+g=; b=BY8mRuziNf9KvYePqagjwWGgJ9MsUgzq1HIJjoub3TBmPqlXuM5Aq3ie3GZKhqzPoL hNU634WsGoyAfB6HGG1OoGwybXpSDTdiMhFKBlZ723F5WVChd93Tr3LK//XSFYHHWgRV IZq2cKu+uiPHSL1GT+meF9aJEtSWAwscKwbwvgE5zFN9o0bqDt3RHOQ5PLL/TnmpLx5m oVG5dC0QT5D0ByjCBSmyJnRFgRqY4guHNc1L+FodUspOBLp0FMd9VBIB9eROXAyfLh/d PNX+2T1L1mcfxlVzOkDbuObEDqcj6oHBNa0bnGiT0V0wQmr9hnipYKPtsbArb3e3PoGP ixpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=khw/gsGZuyzOSP8QVeDEhWS1cx7qkXvQOKH8PglON+g=; b=bE4Iu+jvTfKaqEHWLez4q6W/PNBZDiKaNlc+ckwCSqt9olfiMAIT0lXBBDFA9rnkRX T3Otwuj6ENkHcgOhfRb4C0t2TVFB/q8lx19gLSHA8dowEGm8OJ3QpKFgzsX/3Zxwlh4d 07/a7Zp1E/QXVXW9mOr5yDpGlX6v1zuotLwasl6XEw7MfTjS4Sx9fF1eNxOmKYHJNfTB OCgZSX7rcNt5PujGIFe4F35c3Ab5kCyBz/MrmbEWFwz6AcV7bue/yJj5ZArWWUOrgGb5 92y5h+weUsvU1U9enpGKsiNLFJRSoUadrRMvzK6ZnmCwix4GVsWpe2KkSbAK1yp85eVZ y/Kg== X-Gm-Message-State: AMke39nHwomNATWdrq62NYKGZ0sf2hGXvzdJKX3/F+kca98K6JJ0dXhlF3q5DXEOKqCZJA== X-Received: by 10.107.14.8 with SMTP id 8mr19440380ioo.11.1487616291615; Mon, 20 Feb 2017 10:44:51 -0800 (PST) Original-Received: from zony ([45.2.7.65]) by smtp.googlemail.com with ESMTPSA id 78sm5212200ity.7.2017.02.20.10.44.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 Feb 2017 10:44:50 -0800 (PST) In-Reply-To: <83zihgoi4t.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 20 Feb 2017 20:02:26 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:129588 Archived-At: --=-=-= Content-Type: text/plain tags 25792 patch quit Eli Zaretskii 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: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=v1-0001-Fix-scrolling-with-partial-line-corner-case-Bug-2.patch Content-Description: patch >From f3f948057ae78a551a2f83d89f7918623bed3e6e Mon Sep 17 00:00:00 2001 From: Noam Postavsky 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 --=-=-=--