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

From: Dmitry Gutov <[email-masked]>
Date: Tue, 10 Sep 2024 03:58:58 +0300

On 09/09/2024 14:46, Eli Zaretskii wrote:
>> 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.

Thanks! The patch takes care of the crash AFAICS (no core dump now), but 
alas not of the original test failure.

> 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!

Isn't that the main/only purpose of this variable?

That's how the docstring reads to me, and it's also seems why 
minibuffer-test.el uses it.

In any case, this var is neither necessary nor sufficient (see my next 
email), so sorry if that wasted you time. The fix might still be worth 
installing, though.

> 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);
>