From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Noam Postavsky Newsgroups: gmane.emacs.bugs Subject: bug#26445: 26.0.50; Scroll margin and cursor movement working incorrectly when scrolling over different height lines Date: Thu, 13 Apr 2017 16:05:31 -0400 Message-ID: References: <624e8d20-8e9f-f164-d9e8-b81659eec2f7@web.de> <83wpaogkqr.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: blaine.gmane.org 1492113973 8360 195.159.176.226 (13 Apr 2017 20:06:13 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 13 Apr 2017 20:06:13 +0000 (UTC) Cc: Alexander Miller , 26445@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Apr 13 22:06:09 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 1cyl0K-00025m-Q7 for geb-bug-gnu-emacs@m.gmane.org; Thu, 13 Apr 2017 22:06:09 +0200 Original-Received: from localhost ([::1]:50712 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cyl0Q-00079m-R2 for geb-bug-gnu-emacs@m.gmane.org; Thu, 13 Apr 2017 16:06:14 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52480) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cyl0H-00077d-MX for bug-gnu-emacs@gnu.org; Thu, 13 Apr 2017 16:06:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cyl0E-0000iM-VZ for bug-gnu-emacs@gnu.org; Thu, 13 Apr 2017 16:06:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:47899) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cyl0E-0000iC-S2 for bug-gnu-emacs@gnu.org; Thu, 13 Apr 2017 16:06:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cyl0E-0006Qb-KW for bug-gnu-emacs@gnu.org; Thu, 13 Apr 2017 16:06:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Noam Postavsky Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 13 Apr 2017 20:06:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 26445 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: confirmed Original-Received: via spool by 26445-submit@debbugs.gnu.org id=B26445.149211393924668 (code B ref 26445); Thu, 13 Apr 2017 20:06:02 +0000 Original-Received: (at 26445) by debbugs.gnu.org; 13 Apr 2017 20:05:39 +0000 Original-Received: from localhost ([127.0.0.1]:46095 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cykzq-0006Pm-Vj for submit@debbugs.gnu.org; Thu, 13 Apr 2017 16:05:39 -0400 Original-Received: from mail-oi0-f48.google.com ([209.85.218.48]:35520) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cykzp-0006PT-Ds for 26445@debbugs.gnu.org; Thu, 13 Apr 2017 16:05:37 -0400 Original-Received: by mail-oi0-f48.google.com with SMTP id f22so76726892oib.2 for <26445@debbugs.gnu.org>; Thu, 13 Apr 2017 13:05:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=Yfgp8pc3HpAjlVV5DikikfuOUnBecZ80NZFqWZgDrDc=; b=lsPGdjnPHKz275IDHmkXsO1KE+aJbMrLjlyStR+ybfV+IoutdNayqRVpy1LHDSJdXY umJsnuVZ76SZMYDw/waYh3tsjCuWhEmS57cePyEUzXlTfB7KWtPQQOH2WSw7fuXON+La EEQ+Dzv609LPZxWMHdx5ogvYGawnKc+OKNMezYkrbf1K6DQKSXG1DDeM9rn73QlemHBQ c941nLX1rcL0d7RLNeN71yJKy+/UxH911sM64Dd6G9GkyBnzxVbbWqBnAdaDMOKxwkE0 /Lvp/q+5T/lSW+OB6Y0v7kPep3ZIrqX5AzWFUqe/eldMso0WnzZ3TKyS9z22EiT+baoC 00BA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=Yfgp8pc3HpAjlVV5DikikfuOUnBecZ80NZFqWZgDrDc=; b=hPVjvMu7hUtMuHBeERKrVXrdfmXkvCB6q/lZOsIP/8mSkvKobtmwodUYHCZW2GfmAF M3kLdqimAFGunLxt80aBWR+Aw413cKBcMUo4TZZJkPhvaUfdywvWx7LQArs7TMvgEjpq HrNd8ICS3k/d1TiCZs+3/oQh3r6AIlGbPVqwekzUJfy4B24mKjkQqOuLFWqrrIGIlrdP byC4LMGU4XH7s8N9Ec9WLScTZb9GiUs0AZiImCLWBpNrbazxTNwMZIUa5tfIsR0DSWvW Pee2JDj9JocTbktSM3MEplO45YPtNy+ke+nCORdy0N6KYGE/7in59o5yzPPHOnvX47Ra u83Q== X-Gm-Message-State: AN3rC/4MgoPVNcOMW0gSDknPqaIsE585vpOeW0h/YzWzGk8cjm1CP2h8 ze6o59TMsjOJ7qoPaUmmC3QFQ/ee9A== X-Received: by 10.202.89.139 with SMTP id n133mr2905183oib.70.1492113931793; Thu, 13 Apr 2017 13:05:31 -0700 (PDT) Original-Received: by 10.157.9.178 with HTTP; Thu, 13 Apr 2017 13:05:31 -0700 (PDT) In-Reply-To: <83wpaogkqr.fsf@gnu.org> X-Google-Sender-Auth: CC708jxtgRqa3nE6LrTLp7BkvAc 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:131547 Archived-At: On Thu, Apr 13, 2017 at 3:39 PM, Eli Zaretskii wrote: >> From: Noam Postavsky >> Date: Thu, 13 Apr 2017 15:09:14 -0400 >> Cc: 26445@debbugs.gnu.org >> >> This code in `try_cursor_movement' is what's different for scrolling >> vs non-scrolling lines. >> >> /* If within the scroll margin, scroll. Note that >> MATRIX_ROW_BOTTOM_Y gives the pixel position at which >> the next line would be drawn, and that >> this_scroll_margin can be zero. */ >> if (MATRIX_ROW_BOTTOM_Y (row) > last_y >> || PT > MATRIX_ROW_END_CHARPOS (row) >> /* Line is completely visible last line in window >> and PT is to be set in the next line. */ >> || (MATRIX_ROW_BOTTOM_Y (row) == last_y >> && PT == MATRIX_ROW_END_CHARPOS (row) >> && !row->ends_at_zv_p >> && !MATRIX_ROW_ENDS_IN_MIDDLE_OF_CHAR_P (row))) >> scroll_p = true; > > Not sure what you are saying: do you see some problem in the above > code? If so, where do you see a potential problem. Just noting that this appears to be where the difference between scrolling and not scrolling on the alternating lines in the recipe is decided. Specifically the first test: MATRIX_ROW_BOTTOM_Y (row) > last_y. > >> I think the root issue might be that scroll-margin is given in lines, >> and then it's translated to pixels under the assumption that lines are >> all using the default height. > > If that's the problem, I see no good solutions here, because > scroll-conservatively > 100 explicitly requests to position point as > close to the window edge as possible, and the alternating lines of > different height in the recipe of this bug report force us to stop one > line earlier every other scroll. Am I missing something? I would have to sketch this out on paper to be sure, but you're probably right. > >> Although my initial attempt to make >> window_scroll_margin take different line heights into account doesn't >> seem to have any effect. AFAICT, the next test, PT > >> MATRIX_ROW_END_CHARPOS (row), just triggers instead. > > Not sure how to interpret what you say here. Just that the debugger seemed to be showing me that the divergence between the scrolling and non-scrolling is at the 2nd test after applying the patch below. > If point is beyond > MATRIX_ROW_END_CHARPOS of a row, it means point is not in this row, > because MATRIX_ROW_END_CHARPOS gives the buffer position of the first > character in the next row. There are no coordinates, pixel or > otherwise, involved here. >> modified src/window.c >> @@ -4820,10 +4820,17 @@ window_scroll_margin (struct window *window, >> enum margin_unit unit) >> } >> int max_margin = min ((window_lines - 1)/2, >> (int) (window_lines * ratio)); >> - int margin = clip_to_bounds (0, scroll_margin, max_margin); >> - return (unit == MARGIN_IN_PIXELS) >> - ? margin * frame_line_height >> - : margin; >> + int margin_lines = clip_to_bounds (0, scroll_margin, max_margin); >> + if (unit == MARGIN_IN_LINES) >> + return margin_lines; >> + else >> + { >> + struct it it; >> + init_iterator (&it, window, BEGV, BEGV_BYTE, NULL, DEFAULT_FACE_ID); >> + move_it_to (&it, -1, -1, it.last_visible_y, -1, MOVE_TO_Y); >> + move_it_by_lines (&it, -margin_lines); >> + return it.last_visible_y - it.current_y; >> + } > > Is this a suggested patch? If so, how can it fix the issue? It's not, because it doesn't :) I'm just noting what fails to fix this, for future reference. > When a > line is taller than the canonical height, positioning point on it > might enter the scroll-margin, and we still need to back up, don't we? > IOW, the above code still move "by lines", and will "stutter" if lines > are intermittently of different height. What possible solution could > we come up with in such situations? It seems to me that the user gets > what they asked for. Yes, maybe the answer to this bug is just not to set scroll-conservatively so high then.