GNU bug report logs - #48170
next-line on large lines or images skips unexpectedly to next logical line

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Radon Rosborough <radon.neon@HIDDEN>; dated Sun, 2 May 2021 20:43:03 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 48170 <at> debbugs.gnu.org:


Received: (at 48170) by debbugs.gnu.org; 3 May 2021 17:02:36 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon May 03 13:02:36 2021
Received: from localhost ([127.0.0.1]:47546 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ldbxr-0000ke-SU
	for submit <at> debbugs.gnu.org; Mon, 03 May 2021 13:02:36 -0400
Received: from eggs.gnu.org ([209.51.188.92]:38078)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1ldbxq-0000kX-15
 for 48170 <at> debbugs.gnu.org; Mon, 03 May 2021 13:02:34 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:57996)
 by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <eliz@HIDDEN>)
 id 1ldbxi-0007BX-KE; Mon, 03 May 2021 13:02:27 -0400
Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:3332
 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <eliz@HIDDEN>)
 id 1ldbxZ-0008SK-Lm; Mon, 03 May 2021 13:02:19 -0400
Date: Mon, 03 May 2021 20:02:00 +0300
Message-Id: <8335v37nuf.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Radon Rosborough <radon.neon@HIDDEN>
In-Reply-To: <CADB4rJHBorYf77vhNcKOtox3QvxU1MVgAptObwUhdMwfiM4SCQ@HIDDEN>
 (message from Radon Rosborough on Sun, 2 May 2021 13:41:54 -0700)
Subject: Re: bug#48170: next-line on large lines or images skips unexpectedly
 to next logical line
References: <CADB4rJHBorYf77vhNcKOtox3QvxU1MVgAptObwUhdMwfiM4SCQ@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 48170
Cc: 48170 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Radon Rosborough <radon.neon@HIDDEN>
> Date: Sun, 2 May 2021 13:41:54 -0700
> 
> The bug is that (under certain circumstances) when using `next-line'
> on a long, visually-wrapped line, instead of moving to the next visual
> line, point moves to the next logical line.
> 
> The "certain circumstances" are as follows:
> 1. Point is within a long logical line that is visually wrapped onto
> at least two visual lines (the visual line containing point, and at
> least one subsequent visual line).
> 2. The window line containing point is the bottom-most window line
> that is fully visible.
> 3. The next window line is partially visible, and the pixel height of
> the visible part of that line is less than the default line height (as
> returned by `default-line-height').

Thanks.  Preliminary analysis indicates that this use case was never
supported, since line-move-visual was introduced in Emacs 23.

This is somewhat tricky to debug (and %$#@! Edebug doesn't help), so
stay tuned.

> I did some debugging in the course of identifying the conditions to
> reproduce the bug, and the problematic behavior seems to come down to
> something in the implementation of `line-move-partial'. There's a
> conditional check (<= this-ypos (- dlh)) in `line-move-partial' that
> gets triggered for certain combinations of window sizes and font
> heights, and the code gated behind this check appears to be buggy,
> resulting in the observed behavior.

In my testing this part is never executed.  And it shouldn't be,
because it handles the case where the window is vscrolled and the
current line starts above the top of the window.  Which is not the
case here, at least not with the default frame size and window that is
not too small.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#48170; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 2 May 2021 20:42:39 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun May 02 16:42:39 2021
Received: from localhost ([127.0.0.1]:44620 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ldIvH-0000Zp-7k
	for submit <at> debbugs.gnu.org; Sun, 02 May 2021 16:42:39 -0400
Received: from lists.gnu.org ([209.51.188.17]:59686)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <radon.neon@HIDDEN>) id 1ldIvC-0000Zj-Jx
 for submit <at> debbugs.gnu.org; Sun, 02 May 2021 16:42:37 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:44218)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <radon.neon@HIDDEN>)
 id 1ldIvC-0008Ce-CO
 for bug-gnu-emacs@HIDDEN; Sun, 02 May 2021 16:42:34 -0400
Received: from mail-vk1-xa2a.google.com ([2607:f8b0:4864:20::a2a]:39493)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <radon.neon@HIDDEN>)
 id 1ldIvA-0006C4-Gx
 for bug-gnu-emacs@HIDDEN; Sun, 02 May 2021 16:42:34 -0400
Received: by mail-vk1-xa2a.google.com with SMTP id n74so842017vkc.6
 for <bug-gnu-emacs@HIDDEN>; Sun, 02 May 2021 13:42:31 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=mime-version:from:date:message-id:subject:to;
 bh=lN47883geswu4IPX+xwnpQpkQTzwqLGweoVFdE9/Z4o=;
 b=RUWQw7zElf5JJ5cAXD62h5EBonM9GpUP9MkrPv/nBn4Ygfs8yBoUgIjpfFYDih0Gwz
 +sPO/2o2vxCbnIsNetBNsedsuDPyYLpWt+F80KpG0GoFqPt5Y3/pfNg1aQf1CbgUUZeT
 uavv7s0f6Ki7sKkjGZFLxNNwuAVOoVHtqrjxG8uYoI+rp6RqEpwHefZpzM9ylBezHZwz
 0BKvUbPx0y3kpODT86SGCZacygbXPhjQA9EtwEmyC9bbvrmx9sqh+0+g8fXDVRc84art
 fCTn5WOdqLybJT5F3GLczKy8G5DlbzonIvCUtMlqG7YE2gtkx49rUvskSkzIVyUifHIs
 m52w==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:mime-version:from:date:message-id:subject:to;
 bh=lN47883geswu4IPX+xwnpQpkQTzwqLGweoVFdE9/Z4o=;
 b=iIQeGn3pJ0Joma36QUdq91zOINmxVmDbfZORN/OYMnY0T43QjOkEGy9pMQz9tu/5k5
 06/1J/gZLhSFc8TUPZU/JJCo+t/rD1gEoCe6uwNTHxLmFm7r6y74EvqQFPB5SdFW2ufi
 Xg7eHKRzGHAKByoun6XJgXWcCM0GVGMzaD3Xdzq0EcFTvA35y9AEWAIiAK05pxfunvFS
 SQJLYfQ4x10pi614BEbIBv/NB6lZZkwndTzRIYU9KXXBEuP/VxWfYpbY6Qk3t4iCQbkj
 hEcZRnBuktrCU8Ves2xwjEz4pknDVsNn/l8PZWm/NA09UZEOhDWG6HUDh2wU6vMWpvaI
 2hZg==
X-Gm-Message-State: AOAM530K6PeaoXZLnckP2KFkAc+eR/qFTgGB10KNb8JTVSBNGE4bt5kn
 ugaQrMgG0AMenOuZfqFY2Z6lGJ6Ho3lKXNOp2DRmfpCsESdTWg==
X-Google-Smtp-Source: ABdhPJwTzApqmsivp97EhMuX0+HMJhCJkEO15huVdg2NmaEtURJSq2rPbFIp4Euq7CO5BEs5vjxjrX2NBtx5y4khTcY=
X-Received: by 2002:a1f:d283:: with SMTP id j125mr12667285vkg.9.1619988150588; 
 Sun, 02 May 2021 13:42:30 -0700 (PDT)
MIME-Version: 1.0
From: Radon Rosborough <radon.neon@HIDDEN>
Date: Sun, 2 May 2021 13:41:54 -0700
Message-ID: <CADB4rJHBorYf77vhNcKOtox3QvxU1MVgAptObwUhdMwfiM4SCQ@HIDDEN>
Subject: next-line on large lines or images skips unexpectedly to next logical
 line
To: bug-gnu-emacs@HIDDEN
Content-Type: text/plain; charset="UTF-8"
Received-SPF: pass client-ip=2607:f8b0:4864:20::a2a;
 envelope-from=radon.neon@HIDDEN; helo=mail-vk1-xa2a.google.com
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001,
 RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.3 (-)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.3 (--)

Hi all,

I believe I've identified a bug in the implementation of
`line-move-partial' which occurs with certain pixelwise vertical
scroll positions.

The bug is that (under certain circumstances) when using `next-line'
on a long, visually-wrapped line, instead of moving to the next visual
line, point moves to the next logical line.

The "certain circumstances" are as follows:
1. Point is within a long logical line that is visually wrapped onto
at least two visual lines (the visual line containing point, and at
least one subsequent visual line).
2. The window line containing point is the bottom-most window line
that is fully visible.
3. The next window line is partially visible, and the pixel height of
the visible part of that line is less than the default line height (as
returned by `default-line-height').

This bug can be reproduced in either release 27.2 or the latest
development branch (83a915d3dfafd5f3d737afe1e13b75e4dd3aef96 of
2021-04-25). It does not require any configuration or third-party
packages (emacs -Q).

Because the default line height is fairly small (36px), it is
difficult to set up the pixelwise vertical scroll position
appropriately to trigger the bug, at least by default. Applying a face
with an increased :height property and increasing the text scaling
makes it easier, but I have confirmed that the bug reproduces even
with the default font face, given precise enough positioning.

I have uploaded a video demonstrating the behavior in the latest
development version of Emacs: https://youtu.be/dYMjgLSbGNE

I did some debugging in the course of identifying the conditions to
reproduce the bug, and the problematic behavior seems to come down to
something in the implementation of `line-move-partial'. There's a
conditional check (<= this-ypos (- dlh)) in `line-move-partial' that
gets triggered for certain combinations of window sizes and font
heights, and the code gated behind this check appears to be buggy,
resulting in the observed behavior.

I would be happy to get input about whether others can reproduce this
bug, and/or if you have ideas about the most appropriate way to fix or
work around it.

In case you're wondering how I ran into this issue: I am developing a
music player for Emacs which displays albums in a grid view for
selection, like iTunes. The implementation is to insert images via
`make-image', all in a single logical line, with appropriate margin
properties, and then let Emacs take care of the line-wrapping to form
a grid. Unfortunately, images are essentially very tall lines, which
makes it extremely easy to trigger this bug. The result is that when
you use `next-line' at the bottom of the window, point gets moved all
the way to the end of the buffer, which is no good.

In case it's relevant, I'm running GNOME under Pop!_OS.

Best,
Radon Rosborough
https://github.com/raxod502




Acknowledgement sent to Radon Rosborough <radon.neon@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#48170; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Mon, 3 May 2021 17:15:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.