On May 11, 2024, at 5:41 AM, Eli Zaretskii <eliz@gnu.org> wrote:

From: JD Smith <jdtsmith@gmail.com>
Date: Thu, 9 May 2024 09:31:28 -0400
Cc: 70637@debbugs.gnu.org

I presume this is a more general issue than just :box.  One idea is to add a warning to the Elisp section "Display
Specs That Replace The Text", perhaps at the end:

Note: certain `face' attributes such as `:box' can lead to display artifacts when applied to the replacing
text in a `display' specification.  These attributes may be incorrectly merged with adjacent non-`display'
`face' properties.  This can be mitigated by applying the `face' attributes directly to the text being
replaced, rather than (or in addition to) the `display' replacement text itself.

Actually, this is specific to :box, since only for that attribute we
need to determine the beginning and the end of the box.

Maybe a bit too wordy.

Yes, I agree.  If you can reword it to be specific to :box and to
include an example, I think it would be good.

Feel free to edit:

Note: Using `:box' attributes in replacing `display' text adjacent to normal text with the same `:box' styling can lead to display artifacts.  These can be avoided by applying the `:box' attribute directly to the text being replaced, rather than (or in addition to) the `display' replacement text itself.

;; Causes :box artifacts from the cursor
(progn
  (put-text-property 1 2 'display (propertize "  [" 'face '(:box t)))
  (put-text-property 2 3 'face '(:box t))
  (put-text-property 3 4 'display (propertize "]  " 'face '(:box t))))

;; No :box artifacts
(progn
  (add-text-properties 1 2 '(face (:box t) display "  ["))
  (put-text-property 2 3 'face '(:box t))
  (add-text-properties 3 4 '(face (:box t) display "]  ")))