Issue 8395 - eliminate whitespace before indenting electric chars

This is a PR to address #8395 

I am not super happy about testing the `nonWS` again as is done below in the `||` comparison but I couldn't immediately think of a better way to do this.

As per the issue discussion, if the line has non-whitespace characters, the whitespace is not stripped.