Cherry pick less fix from CodeMirror

This fixes issue #6160.