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 15:09:14 -0400 Message-ID: References: <624e8d20-8e9f-f164-d9e8-b81659eec2f7@web.de> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: blaine.gmane.org 1492110614 29326 195.159.176.226 (13 Apr 2017 19:10:14 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 13 Apr 2017 19:10:14 +0000 (UTC) Cc: 26445@debbugs.gnu.org To: Alexander Miller Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Apr 13 21:10: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 1cyk88-0007RD-Nn for geb-bug-gnu-emacs@m.gmane.org; Thu, 13 Apr 2017 21:10:08 +0200 Original-Received: from localhost ([::1]:50558 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cyk8B-0001fy-V4 for geb-bug-gnu-emacs@m.gmane.org; Thu, 13 Apr 2017 15:10:11 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50047) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cyk85-0001fZ-1i for bug-gnu-emacs@gnu.org; Thu, 13 Apr 2017 15:10:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cyk82-0006Kq-8X for bug-gnu-emacs@gnu.org; Thu, 13 Apr 2017 15:10:04 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:47816) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cyk82-0006Ke-4V for bug-gnu-emacs@gnu.org; Thu, 13 Apr 2017 15:10:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cyk81-0001SQ-UK for bug-gnu-emacs@gnu.org; Thu, 13 Apr 2017 15:10:01 -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 19:10:01 +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: Original-Received: via spool by 26445-submit@debbugs.gnu.org id=B26445.14921105625549 (code B ref 26445); Thu, 13 Apr 2017 19:10:01 +0000 Original-Received: (at 26445) by debbugs.gnu.org; 13 Apr 2017 19:09:22 +0000 Original-Received: from localhost ([127.0.0.1]:46013 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cyk7N-0001RP-QD for submit@debbugs.gnu.org; Thu, 13 Apr 2017 15:09:21 -0400 Original-Received: from mail-oi0-f49.google.com ([209.85.218.49]:34286) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cyk7M-0001R8-GP for 26445@debbugs.gnu.org; Thu, 13 Apr 2017 15:09:20 -0400 Original-Received: by mail-oi0-f49.google.com with SMTP id g204so75474908oib.1 for <26445@debbugs.gnu.org>; Thu, 13 Apr 2017 12:09:20 -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=/gDDfQb2tAKg1Y1P6X8DO40hb6EZQyZ8qKIdhhJe5ug=; b=EXDJF7r7CjBokkFP3hptVzOOuZCHsfYeInF8yxSh8rfciC7U54Ei24wAAwNBQWRe6A 1OiaCMjPQmh2i6T0u0jzbvijEfc9q3mDLWWGeJPiLuImQ92M9hodP2mjF5XL5Igvlg+n ZLC8bHDoC46mWTCgd8iYqv0kr+HgxrYZ/MoYNJgg3LCTCZs6IMJ1ci7kAVEPj0js1bJM sq81YeEMPNz4dy8Lun+uWH49FNwqIPzEf9e0QBDVw7+tbXbb/DkLaC+BVFXdeHZK+w6b nKbWSVyqXcA+PSQp7QzTTQPu88+PpspHp5gXrYjg7uTD4ty8iYiaqIkmqTnQpugQlKOp IAwQ== 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=/gDDfQb2tAKg1Y1P6X8DO40hb6EZQyZ8qKIdhhJe5ug=; b=TI/pkiHSvqCk39Qwvb2N5wXABaYRzUeKC1AFfLA1Q5zi2nGyeh6S8Qu7vTNxh4JzRq hKcxC4HdX200fuZRIfqD/KHOmuJWNBu166kmqL+W0+SCxkz1uu1GFaJc65cYzPCMioY9 tpjTKieVekX98vz5MvcbixFFrvzj7q6v50/jsNaum86wfvzm8xZ9n8JdXffFax5ZLP6u b+42RS6By675SkyWhZ4Qi9z00gEGHiBAq1WxTvdVAAR2bNf/Bm12XWGT31aDrKN2RW7R O+rAXDTUA6IoHoLSW847MERHIkVnp3mP6+jq4BvjhcbgqKHT56r+dqKbmUUbajQQt3hA wBRw== X-Gm-Message-State: AN3rC/5S6uss8I+/hwc4nZcunwa1LyPubHW/upL5As/6otTQc0H1/E6E G+U6SMV4TRYJ0jiHC6d4G5Ohzhl/og== X-Received: by 10.157.43.35 with SMTP id o32mr3372011otb.79.1492110554718; Thu, 13 Apr 2017 12:09:14 -0700 (PDT) Original-Received: by 10.157.9.178 with HTTP; Thu, 13 Apr 2017 12:09:14 -0700 (PDT) In-Reply-To: <624e8d20-8e9f-f164-d9e8-b81659eec2f7@web.de> X-Google-Sender-Auth: NsmDmZgOFC0d2bN9ZU7su5zmedE 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:131542 Archived-At: found 26445 24.5 tag 26445 confirmed severity 26445 minor quit On Tue, Apr 11, 2017 at 12:50 PM, Alexander Miller wrote: > This is probably a continuation of bug#25792. The symptoms are similar, but this one seems to be a long-standing bug, I get the same behaviour in 24.5 (haven't tested earlier versions, but I wouldn't expect anything different). 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; 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. 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. 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; + } } else return 0;