From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#5718: scroll-margin in buffer with small line count. Date: Sat, 21 Jan 2017 21:17:05 +0200 Message-ID: <83d1fg5iku.fsf@gnu.org> References: <4B9D1C61.70903@gmail.com> <87mvkjy0l5.fsf@users.sourceforge.net> <83fuqbfhpb.fsf@gnu.org> <87a8ggwcoo.fsf@users.sourceforge.net> <83inv4cc0s.fsf@gnu.org> <87d1ka17dr.fsf@users.sourceforge.net> <834m5l9g1d.fsf@gnu.org> <874m5j19wi.fsf@users.sourceforge.net> <83zina75pa.fsf@gnu.org> <87pok555q4.fsf@users.sourceforge.net> <831swfcmhz.fsf@gnu.org> <871sw6z32n.fsf@users.sourceforge.net> <83o9zaax8x.fsf@gnu.org> <87k29wxam1.fsf@users.sourceforge.net> <83a8ar9bl6.fsf@gnu.org> <87pojguu7m.fsf@users.sourceforge.net> Reply-To: Eli Zaretskii NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1485026397 25389 195.159.176.226 (21 Jan 2017 19:19:57 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 21 Jan 2017 19:19:57 +0000 (UTC) Cc: ahyatt@gmail.com, 5718@debbugs.gnu.org, gavenkoa@gmail.com To: npostavs@users.sourceforge.net Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Jan 21 20:19:51 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 1cV1CZ-0006Bz-9f for geb-bug-gnu-emacs@m.gmane.org; Sat, 21 Jan 2017 20:19:51 +0100 Original-Received: from localhost ([::1]:33064 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cV1Ce-0003W2-Av for geb-bug-gnu-emacs@m.gmane.org; Sat, 21 Jan 2017 14:19:56 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43835) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cV1As-0002l5-RD for bug-gnu-emacs@gnu.org; Sat, 21 Jan 2017 14:18:08 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cV1Ao-00023E-Qq for bug-gnu-emacs@gnu.org; Sat, 21 Jan 2017 14:18:05 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:39552) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cV1Ao-00022x-Mc for bug-gnu-emacs@gnu.org; Sat, 21 Jan 2017 14:18:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cV1Ao-0008A6-F3 for bug-gnu-emacs@gnu.org; Sat, 21 Jan 2017 14:18:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 21 Jan 2017 19:18:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 5718 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 5718-submit@debbugs.gnu.org id=B5718.148502626031346 (code B ref 5718); Sat, 21 Jan 2017 19:18:02 +0000 Original-Received: (at 5718) by debbugs.gnu.org; 21 Jan 2017 19:17:40 +0000 Original-Received: from localhost ([127.0.0.1]:37751 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cV1AS-00089W-F5 for submit@debbugs.gnu.org; Sat, 21 Jan 2017 14:17:40 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:52820) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cV1AQ-00089F-VU for 5718@debbugs.gnu.org; Sat, 21 Jan 2017 14:17:39 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cV1AI-0001sC-KY for 5718@debbugs.gnu.org; Sat, 21 Jan 2017 14:17:33 -0500 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:34178) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cV1A3-0001n5-GO; Sat, 21 Jan 2017 14:17:15 -0500 Original-Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:3313 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1cV1A2-00062b-1T; Sat, 21 Jan 2017 14:17:15 -0500 In-reply-to: <87pojguu7m.fsf@users.sourceforge.net> (npostavs@users.sourceforge.net) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] 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:128300 Archived-At: > From: npostavs@users.sourceforge.net > Cc: 5718@debbugs.gnu.org, ahyatt@gmail.com, gavenkoa@gmail.com > Date: Sat, 21 Jan 2017 13:46:37 -0500 > > > /* See if point is on a partially visible line at the end. */ > > if (it.what == IT_EOB) > > partial_p = it.current_y + it.ascent + it.descent > it.last_visible_y; > > else > > { > > move_it_by_lines (&it, 1); > > partial_p = it.current_y > it.last_visible_y; > > } > > > > (This is preceded by moving the iterator to the point's screen line or > > to EOB, whichever comes first.) The value it.current_y is the Y > > coordinate of the top edge of a glyph row (the value is zero for the > > first screen line), so if it.last_visible_y is farther away from that > > than the height of the glyph row, that glyph row is fully visible; > > otherwise it isn't. > > I'm not entirely clear why there is a branch in that code. Because of line-spacing, perhaps? Did you test your code when line-spacing is at non-default value? In general, it is safer to go to the next screen line than reason about where it will start. > +int > +partial_line_height (const struct it *it_origin) > +{ > + struct it it = *it_origin; When you copy the iterator structure and modify the copy, you need to save and restore the bidi cache, using SAVE_IT and RESTORE_IT macros. Otherwise, the code which calls this function will work incorrectly if it uses the original iterator after the call, because the bidi cache is not restored to its state before the call.