changed to using CodeMirror.runMode for better performance