Fixed issue where caret position was not being updated when switching between files