How to make “formats” dropdown styles apply to only the selected text?

How can I make the format styles dropdown in the classic editor apply to ONLY the selected text? Right now it is applying to the nearest line break from the selected text, I don’t like that.

Here is the code in my functions.php file: