fix for #8395 

this PR addresses #8395 and is a 2nd attempt.  I refactored my fix based on feedback from @peterflynn and @redmunds in #8426
I added this 2nd conditional to handle the situation where there is actual text on the line.  This will remove the whitespace between the electric char and the first non whitespace.  That behaviour is contrary to our conversation in the issue, but it seemed more consistent with the prior case (all whitespace).  If this is not desired, then the else condition can be removed.