Correcting event handler for codemirror