Subject: Re: bug#72765: Eglot + Clangd + Company + non-empty suffix = duplicate text

From: Eli Zaretskii <[email-masked]>
Date: Mon, 09 Sep 2024 14:46:09 +0300

> Date: Mon, 9 Sep 2024 03:20:01 +0300
> Cc: Eli Zaretskii <[email-masked]>, [email-masked]
> From: Dmitry Gutov <[email-masked]>
> 
> > This now aborts (segfault?).  At least something different.
> > 
> > So, for the record, before this patch with the latest emacs-30, I get the
> > results in failure1.txt and with your last redisplay-skip-initial-frame patch
> > I get failure2.txt.
> > 
> > I've produced these files with
> > 
> > make -C test eglot-tests SELECTOR=\"rust-completion\" 2>&1 | tee failure1.txt
> 
> So it's reproducible. Great!
> 
> Could someone look into the segfault? The repro steps are simple:
> 
> 1) apply the patch above,
> 2) run 'make -C test eglot-tests' or the longer command above which 
> executes just one test from that file.
> 
> The backtrace that I managed to generate is attached.

Thanks.  Please try the patch below.

P.S. I'm not at all sure this is the last segfault you will see
because you are playing with fire: you are not supposed to reset
redisplay-skip-initial-frame to nil in batch-mode tests that test
redisplay-related features!

diff --git a/src/xdisp.c b/src/xdisp.c
index bf7d84c..a1319e7 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -22089,7 +22089,8 @@ #define GIVE_UP(X) return 0
 
   /* Window must either use window-based redisplay or be full width.  */
   if (!FRAME_WINDOW_P (f)
-      && (!FRAME_LINE_INS_DEL_OK (f)
+      && (FRAME_INITIAL_P (f)
+	  || !FRAME_LINE_INS_DEL_OK (f)
 	  || !WINDOW_FULL_WIDTH_P (w)))
     GIVE_UP (4);