Subject: bug#31067: 27.0.50; After-string hidden by subsequent invisible text

From: Stefan Monnier <[email-masked]>
Date: Wed, 04 Apr 2018 22:28:59 -0400

Package: Emacs
Version: 27.0.50

In a fresh Emacs session define:

    (defun foo ()
      (interactive)
      (with-current-buffer "*scratch*"
        (add-to-invisibility-spec '(foo . t))
        (let ((beg (point)))
          (insert "text")
          (let ((ol1 (make-overlay beg (point))))
            (overlay-put ol1 'after-string "!after!")
            (overlay-put ol1 'evaporate t)))
        (let ((beg (point)))
          (insert "\nhidden")
          (let ((ol1 (make-overlay beg (point))))
            (overlay-put ol1 'invisible 'foo)
            (overlay-put ol1 'evaporate t)))))

and then try it with `M-x foo`.
The result for me is to display "text...", whereas I would have expected
"text!after!...".

I.e. the after-string which I placed over "text" gets hidden by
`invisible` property of the overlay placed on the immediately following
"\nhidden".

I know these kinds of interactions are pretty delicate and often
somewhat arbitrary (several behaviors are valid and we just have to pick
one), but I think in this case it is clearly an error.

        Stefan