Search code examples
javascriptcodemirror

Cursor is before the line number during page load


I'm using code mirror for the first time and finding it to be awesome!

So, when the page loads for the first time, the cursor goes before line number. But after I type couple of lines, all the texts start showing in proper area after line number. Any thoughts? These are the values that I've set.

var myCodeMirror = CodeMirror.fromTextArea(elt, {
  lineNumbers: true,
  mode: "xml",
  htmlMode: true, 
  lineSeparator: null,
  theme: "default",
  indentUnit: 2,
  tabSize: 4,
  indentWithTabs: true,
  lineWrapping: true, 
  tabindex: 1,
  autofocus: true,
  gutter: true,
  lineWrapping: true  
});
myCodeMirror.setSize(null,1000);

enter image description here


Solution

  • Adding myCodeMirror.refresh(); after myCodeMirror.setSize(null,1000); solved the issue.