When I tried out the original code, I think it behaved like I expected. I'm using SublimeText as the basis for the behavior, by the way.