Subject: Re: bug#64101: 29.0.91; Eglot inlay hints rendered out of order

From: Stefan Monnier <[email-masked]>
Date: Sun, 18 Jun 2023 11:20:05 -0400

>> Anyway, can you explain this?
> [ Revised answer: ]  Yes.

The patch below won't fix it, but maybe it can help someone else write
an actual fix?  AFAICT the place that needs fixing is the one in xdisp.c

        Stefan

diff --git a/src/buffer.c b/src/buffer.c
index 0c46b201586..26938dc5f78 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -3376,6 +3376,10 @@ record_overlay_string (struct sortstrlist *ssl, Lisp_Object str,
    that string via PSTR, if that variable is non-NULL.  The storage of
    the concatenated strings may be overwritten by subsequent calls.  */
 
+/* AFAICT, this is used only by indent.c:compute_motion,
+   which does not actually care about the ordering of the strings
+   but only its total width.  */
+
 ptrdiff_t
 overlay_strings (ptrdiff_t pos, struct window *w, unsigned char **pstr)
 {
@@ -3416,6 +3420,7 @@ overlay_strings (ptrdiff_t pos, struct window *w, unsigned char **pstr)
 			       endpos - startpos);
     }
 
+  /* FIXME: Use `sort_overlays` instead?  */
   if (overlay_tails.used > 1)
     qsort (overlay_tails.buf, overlay_tails.used, sizeof (struct sortstr),
 	   cmp_for_strings);
diff --git a/src/xdisp.c b/src/xdisp.c
index 8bcf2acfe04..f487dfbb5ba 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -6794,6 +6794,7 @@ #define RECORD_OVERLAY_STRING(OVERLAY, STRING, AFTER_P)			\
 
   /* Sort entries.  */
   if (n > 1)
+    /* FIXME: Use `sort_overlays` instead?  */
     qsort (entries, n, sizeof *entries, compare_overlay_entries);
 
   /* Record number of overlay strings, and where we computed it.  */