Thanks for reporting the bug. That is a regression in Emacs 27, and I reproduced the bug there, so I installed the attached patch (which is smaller and which I think is better) into the emacs-27 branch. PS. Although I unfortunately mispelled your name in the attached file, I fixed the misspelling in the corresponding ChangeLog.3 file, which is what will be distributed in the next Emacs release. See: https://git.savannah.gnu.org/cgit/emacs.git/commit/?h=emacs-27&id=1d10885763287f03a5fb348ba27715e049bb48f8