Check when caret inside template, and don't try to create invalid range then EA-105522 fixed #KT-20256 fixed