I agree that it looks inconsistent, but we can't do it in your consistent way since keydown or keypress events do not trigger _beginSession() immediately. _beginSession() is triggered in handleChange() after CodeMirror has generated the character that the user typed in. Since we want to check the correct editor in handleChange() before we trigger _beginSession(), we definitely can't set the editor in there.