detect correct position for text when special chars present

https://codio.myjetbrains.com/youtrack/issue/codio-4782