From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#19200: Point adjustemnt moves *into* invisible text Date: Mon, 21 Mar 2016 20:28:05 +0200 Message-ID: <83h9fz65ze.fsf@gnu.org> References: <87mvpskb84.fsf@web.de> <87io0gbmpl.fsf@web.de> <87d1qnevco.fsf@web.de> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1458584970 8167 80.91.229.3 (21 Mar 2016 18:29:30 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 21 Mar 2016 18:29:30 +0000 (UTC) Cc: michael_heerdegen@web.de, jonas@bernoul.li, 19200@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Mar 21 19:29:14 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ai4Zm-0004jF-58 for geb-bug-gnu-emacs@m.gmane.org; Mon, 21 Mar 2016 19:29:14 +0100 Original-Received: from localhost ([::1]:59684 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ai4Zl-0005Be-AC for geb-bug-gnu-emacs@m.gmane.org; Mon, 21 Mar 2016 14:29:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43938) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ai4Zh-0005BY-6g for bug-gnu-emacs@gnu.org; Mon, 21 Mar 2016 14:29:10 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ai4Zd-0001Ud-56 for bug-gnu-emacs@gnu.org; Mon, 21 Mar 2016 14:29:09 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:60128) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ai4Zd-0001UY-1o for bug-gnu-emacs@gnu.org; Mon, 21 Mar 2016 14:29:05 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ai4ZZ-0003mA-Oo for bug-gnu-emacs@gnu.org; Mon, 21 Mar 2016 14:29:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 21 Mar 2016 18:29:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 19200 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 19200-submit@debbugs.gnu.org id=B19200.145858492614491 (code B ref 19200); Mon, 21 Mar 2016 18:29:01 +0000 Original-Received: (at 19200) by debbugs.gnu.org; 21 Mar 2016 18:28:46 +0000 Original-Received: from localhost ([127.0.0.1]:57254 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ai4ZJ-0003le-H0 for submit@debbugs.gnu.org; Mon, 21 Mar 2016 14:28:45 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:52861) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ai4ZH-0003lR-Sp for 19200@debbugs.gnu.org; Mon, 21 Mar 2016 14:28:44 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ai4ZB-0001RN-Oq for 19200@debbugs.gnu.org; Mon, 21 Mar 2016 14:28:38 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:33456) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ai4Z2-0001QD-O6; Mon, 21 Mar 2016 14:28:28 -0400 Original-Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:3036 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1ai4Z1-0005b4-TE; Mon, 21 Mar 2016 14:28:28 -0400 In-reply-to: (message from Stefan Monnier on Mon, 21 Mar 2016 11:36:23 -0400) 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-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:115254 Archived-At: > From: Stefan Monnier > Date: Mon, 21 Mar 2016 11:36:23 -0400 > Cc: 19200@debbugs.gnu.org, Jonas Bernoulli > > >> The way point-adjustment is defined is too conservative for that. > >> So I suggest you try and make you code more robust w.r.t the position of > >> point within an invisible region in any case. > > Well, we just want that cursor movement starting from a visible position > > not end up at an invisible position - the docs seem to suggest that this > > should not happen, right? > > It doesn't guarantee it in all cases, no. E.g. it won't work if the > command that moves point started/ended in another buffer, or if the > command set disable-point-adjustment, plus a few other cases. > > > We have the following, very simple situation: > > > Line N > > { M invisible lines here } > > Line N+M+1 > > > Line N and Line N+M+1 are completely visible, and displayed after each > > other. Point is at the start of Line N, no invisible text near that > > position. Now I hit [down] one time and end up somewhere inside the > > invisible text in between. > > I agree it's a bug. I'm just pointing out that even if we fix this bug, > there will be other cases which ae not considered bugs where point will > end up in the middle of the invisible text, and where it would be odd > for your code to then operate on the selection at the "current line" > since that's not the line that the user is actually seeing. > > So, yes, point-adjustment needs to be fixed (this is bug#19200), but > Magit also needs to be fixed anyway (and after that fix, it won't care > about bug#19200 nearly as much, I think). Can someone tell me why you think point adjustment has anything to do with the original report for this bug? Because I fail to see any connection; maybe I'm missing something. What I see is that vertical-motion, called by next-line's subroutines, ends up at position 5, because when it tries to get to column zero, it skips the invisible text between positions 3 and 5. It stops at 5 because the function called to move to the goal column can only move within a single display line. IOW, this is a simple artifact of the implementation of vertical-motion. Michael, does the patch below fix the Magit problem? (It does fix the simple test case presented by Stefan at the beginning of this bug report.) diff --git a/src/indent.c b/src/indent.c index d5162e3..e10b084 100644 --- a/src/indent.c +++ b/src/indent.c @@ -2222,7 +2222,8 @@ whether or not it is currently displayed in some window. */) an addition to the hscroll amount. */ if (lcols_given) { - move_it_in_display_line (&it, ZV, first_x + to_x, MOVE_TO_X); + if (it.current_x < first_x + to_x) + move_it_in_display_line (&it, ZV, first_x + to_x, MOVE_TO_X); /* If we find ourselves in the middle of an overlay string which includes a newline after current string position, we need to move by lines until we get out of the string,