fixed bug with exception when caret wasn't visible