From mboxrd@z Thu Jan  1 00:00:00 1970
Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail
From: Eli Zaretskii <eliz@gnu.org>
Newsgroups: gmane.emacs.bugs
Subject: bug#70038: 29.3.50;
 Shift up/down in buffer with images on M-x other-window with some
 fonts
Date: Sat, 06 Apr 2024 15:33:59 +0300
Message-ID: <86bk6m3c20.fsf@gnu.org>
References: <87ttkrl8w1.fsf@gmail.com> <86zfuihp7t.fsf@gnu.org>
 <87bk6yl4hu.fsf@gmail.com> <8734sal2bc.fsf@gmail.com>
 <87wmpm2rd7.fsf@zohomail.eu>
Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214";
	logging-data="21825"; mail-complaints-to="usenet@ciao.gmane.io"
Cc: Rahguzar <rahguzar@zohomail.eu>, rdiaz02@gmail.com, 70038@debbugs.gnu.org
To: Ramon Diaz-Uriarte <r.diaz@uam.es>, Po Lu <luangruo@yahoo.com>
Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Apr 06 14:35:18 2024
Return-path: <bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org>
Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org
Original-Received: from lists.gnu.org ([209.51.188.17])
	by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
	(Exim 4.92)
	(envelope-from <bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org>)
	id 1rt5GP-0005SM-QQ
	for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 06 Apr 2024 14:35:17 +0200
Original-Received: from localhost ([::1] helo=lists1p.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.90_1)
	(envelope-from <bug-gnu-emacs-bounces@gnu.org>)
	id 1rt5G8-0003d8-Fq; Sat, 06 Apr 2024 08:35:00 -0400
Original-Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <Debian-debbugs@debbugs.gnu.org>)
 id 1rt5G7-0003cn-2y
 for bug-gnu-emacs@gnu.org; Sat, 06 Apr 2024 08:34:59 -0400
Original-Received: from debbugs.gnu.org ([2001:470:142:5::43])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <Debian-debbugs@debbugs.gnu.org>)
 id 1rt5G6-0007gA-Pi
 for bug-gnu-emacs@gnu.org; Sat, 06 Apr 2024 08:34:58 -0400
Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2)
 (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1rt5GC-0008P2-GW
 for bug-gnu-emacs@gnu.org; Sat, 06 Apr 2024 08:35:04 -0400
X-Loop: help-debbugs@gnu.org
Resent-From: Eli Zaretskii <eliz@gnu.org>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces@debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@gnu.org
Resent-Date: Sat, 06 Apr 2024 12:35:04 +0000
Resent-Message-ID: <handler.70038.B70038.171240686432095@debbugs.gnu.org>
Resent-Sender: help-debbugs@gnu.org
X-GNU-PR-Message: followup 70038
X-GNU-PR-Package: emacs
Original-Received: via spool by 70038-submit@debbugs.gnu.org id=B70038.171240686432095
 (code B ref 70038); Sat, 06 Apr 2024 12:35:04 +0000
Original-Received: (at 70038) by debbugs.gnu.org; 6 Apr 2024 12:34:24 +0000
Original-Received: from localhost ([127.0.0.1]:38526 helo=debbugs.gnu.org)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <debbugs-submit-bounces@debbugs.gnu.org>)
 id 1rt5FW-0008LX-RO
 for submit@debbugs.gnu.org; Sat, 06 Apr 2024 08:34:23 -0400
Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50162)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@gnu.org>) id 1rt5FQ-0008Jv-W7
 for 70038@debbugs.gnu.org; Sat, 06 Apr 2024 08:34:21 -0400
Original-Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@gnu.org>)
 id 1rt5FD-0007Uy-EN; Sat, 06 Apr 2024 08:34:03 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=xIVQETBrOlwXbmFGAIog8ecddDATzoxKI2wInjGzefk=; b=ZFcOgipxKXuS
 JD1DAhLsF6UUpWIRGfeBN/zJZeOlHnQ2NpMu8hp8xNso7nw+JpzUS9pgiVvH4jIpGVxMWN7cmr7J/
 5R3Po9/HIvVCjOojnK2e8z31pIfATL+A8VY5P2tFBOC/AEQMS+iLnI5G2U1jLBmI2SP5rshseXV4G
 h+nHrIt2kLZ4sT8IOcCC5VWO8IqrNu4BfMvJcEsS/bkbB8W+tIOamWwnTc/k1jvpRMDxzlGvl+m0h
 I8YQUbwCjc62LK78dQaxanUz8xnwF1UZ2dQuhvskLFTChRDD3ZQsxdDR6mAdmUvQaTTdeDL4ErkBl
 HmplUUqG3ci+M3mNV8TXeg==;
In-Reply-To: <87wmpm2rd7.fsf@zohomail.eu> (message from Rahguzar on Thu, 28
 Mar 2024 18:24:32 +0100)
X-BeenThere: debbugs-submit@debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
X-BeenThere: bug-gnu-emacs@gnu.org
List-Id: "Bug reports for GNU Emacs,
 the Swiss army knife of text editors" <bug-gnu-emacs.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/bug-gnu-emacs>,
 <mailto:bug-gnu-emacs-request@gnu.org?subject=unsubscribe>
List-Archive: <https://lists.gnu.org/archive/html/bug-gnu-emacs>
List-Post: <mailto:bug-gnu-emacs@gnu.org>
List-Help: <mailto:bug-gnu-emacs-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/bug-gnu-emacs>,
 <mailto:bug-gnu-emacs-request@gnu.org?subject=subscribe>
Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org
Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org
Xref: news.gmane.io gmane.emacs.bugs:282788
Archived-At: <http://permalink.gmane.org/gmane.emacs.bugs/282788>

> From: Rahguzar <rahguzar@zohomail.eu>
> Cc: Eli Zaretskii <eliz@gnu.org>, 70038@debbugs.gnu.org
> Date: Thu, 28 Mar 2024 18:24:32 +0100
> 
> I can also reproduce this now! And vertico mode can be replaced with the
> builtin icomplete-vertical-mode. So, the following recipe starting with
> emacs -Q works for me:
> 
> 1) Paste
> (let ((height (/ (* 2 (frame-pixel-height)) 15)))
>   (icomplete-vertical-mode)
>   (defun pin-vscroll-down (win)
>     (set-window-vscroll win (/ height 2) t))
>   (let ((image1 (create-image "~/Downloads/image1.png" nil nil :height height))
>         (image2 (create-image "~/Downloads/image2.png" nil nil :height height))
>         (image3 (create-image "~/Downloads/image3.png" nil nil :height height)))
>     (with-current-buffer (get-buffer-create "*image-scroll-test*")
>       (insert " \n \n \n \n \n \n")
>       (put-image image1 1)
>       (put-image image2 5)
>       (put-image image3 9)
>       ;; With larger image sizes (goto-char 3)
>       ;; also consistently triggers the problem.
>       (goto-char 11)
>       (add-hook 'pre-redisplay-functions #'pin-vscroll-down nil t))
>     (split-window-right)
>     (other-window 1)
>     (switch-to-buffer "*image-scroll-test*")))
> 
> into scratch buffer.
> 
> 2) Evaluate the form above using `C-M-x`.
> 
> 3) Type M-x t
> 
> 4) Wait till minibuffer expands to show completions, then type `C-g` to
> quit minibuffer.
> 
> 5) Typing `C-x 0` results in the window with images losing vscroll.

Po Lu, I'm looking at this part of redisplay_window:

   force_start:

    /* Handle case where place to start displaying has been specified,
       unless the specified location is outside the accessible range.  */
    if (w->force_start)
      {
	/* We set this later on if we have to adjust point.  */
	int new_vpos = -1;

	w->force_start = false;

	/* The vscroll should be preserved in this case, since
	   `pixel-scroll-precision-mode' must continue working normally
	   when a mini-window is resized.  (bug#55312) */
	if (!w->preserve_vscroll_p || !window_frozen_p (w))  <<<<<<<<<<<<<<<
	  w->vscroll = 0;

	w->preserve_vscroll_p = false;
	w->window_end_valid = false;

where you added the condition for resetting w->vscroll in commit
fd8eaa72a61, and I'm thinking that perhaps the condition should be

	if (!w->preserve_vscroll_p && !window_frozen_p (w))

instead?  If not, can you explain why we use OR and not AND there?

Ramon, if you replace "||" with "&&" in the above condition, does the
problem go away for you also when you change fonts, as you described
in https://debbugs.gnu.org/cgi/bugreport.cgi?bug=70038#29 ?