I think there is some confusion about the “leading” word. The only “leading” whitespace on your 3rd image is the one that is still there on the 4th image.
Whitespace is considered “per line”. The editor doesn’t care about what the code means, it just removes whitespace at the end of the line, except for the line break.
On line 1 there is none leading or trailing.
On line 2, there are only spaces, and no content. The editors considers this space to be at the end of the line (trailing), and removes it.
On line 3 there are two leading spaces before @doc, and they are still there after the cleanup.
On line 4, there are two leading spaces too, before “Some”, and they are still there. After the content (after the word “here”) there is trailing whitespace, and it gets removed.
And so on.
So no, the editor does not consider all whistespace as trailing. It does not remove leading whitespace.