If the cursor is not collapsed (e.g., a range is selected, and then "replaced" with a new line), this will produce slightly odd behaviour, as line 381 will return the first applied style, which may not be the style at the cursor's focus node. Again, not sure if this is a big deal, but might be worth noting in a comment.