tracking correct indentation when switching between modes