editor: add logging to change tracker.
editor: chose more appropriate line when doing insertions.

Also, fix a potential double line removal that could cause state to
get out of sync.