Fix editor bugs with the visual vs. text state

This seems prone to race conditions maybe?