Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Codemirror cursor position offset

I'm using code mirror to display, highlight and edit xml in a web page but I am having a problem with the cursor position being offset from the insert position so that if you delete a character from where the blinking cursor is, a character before the one you would expect gets deleted instead. I am assuming its a css clash with my current page because it works well outside my page, but cant find the clash anywhere. Has anyone had similar issues or know what to do?

like image 576
chrisp_68 Avatar asked Oct 22 '11 09:10

chrisp_68


2 Answers

Further investigation shows that the page had padding set on all divs embedded in fieldsets which was the cause of the problem.

like image 139
chrisp_68 Avatar answered Sep 30 '22 07:09

chrisp_68


The following lines fixed the issue for me:

.CodeMirror pre {
    white-space: pre-wrap;
    word-break: break-all;
    word-wrap: break-word;
}

I'm using lineWrapping: true in my CodeMirror configuration. Setting that to false works as well.

like image 36
rebagliatte Avatar answered Sep 30 '22 08:09

rebagliatte