Looks fine, but would need, I think, a decent amount of testing:
* In eglot.el, being validated by both Andrii and you for your particular use cases.
* In bare emacs-lisp-mode, with multiple eldoc-documentation-strategy options. It should
behave exactly the same before and after the patch, as elisp doesn't use invisible stuff.
* In other situations you can think of. Like variations on eldoc-area-use-multiline-p and
eldoc-echo-area-display-truncation-messages. Again, here the behaviour should be
equivalent pre- and post- patch.
Just noting this because in my memory this code is somewhat hairy. That
said, the patch "looks" really fine :-)
Thanks,
João