Cannot read properties of undefined (reading 'length')
See original GitHub issueenvironment:
vue3, vue-cli ^4.5 “codemirror”: “^5.63.3” chrome browser 93.0.4577.82(x86_64)
problem:
switch cm from small window to fullscreen, then click any where of the fullscreen invoke exception message in the browser console tab: codemirror.js?56b3:2354 Uncaught TypeError: Cannot read properties of undefined (reading ‘length’) at mapFromLineView (codemirror.js?56b3:2354) at prepareMeasureForLine (codemirror.js?56b3:2407) at cursorCoords (codemirror.js?56b3:2658) at scrollPosIntoView (codemirror.js?56b3:3460) at endOperation_finish (codemirror.js?56b3:3917) at endOperations (codemirror.js?56b3:3836) at eval (codemirror.js?56b3:3819) at finishOperation (codemirror.js?56b3:2058) at endOperation (codemirror.js?56b3:3816) at HTMLDivElement.eval (codemirror.js?56b3:3953)
the vue function to switch cm view mode is: fullScreen(type){ cm.setOption(“fullScreen”, !cm.getOption(“fullScreen”)); }
i have debug the code where exception throws,
function mapFromLineView(lineView, line, lineN) { if (lineView.line == line) { return {map: lineView.measure.map, cache: lineView.measure.cache} } for (var i = 0; i < lineView.rest.length; i++) { if (lineView.rest[i] == line) { return {map: lineView.measure.maps[i], cache: lineView.measure.caches[i]} } } for (var i$1 = 0; i$1 < lineView.rest.length; i$1++) { if (lineNo(lineView.rest[i$1]) > lineN) { return {map: lineView.measure.maps[i$1], cache: lineView.measure.caches[i$1], before: true} } } }
when click on the fullscreen cm the method mapFromLineView will execute second for loop(first if not return true),the lineView.rest is undefine, so invoke “Uncaught TypeError: Cannot read properties of undefined (reading ‘length’)” exception
every click anywhere will throw the same exception
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (2 by maintainers)
Top GitHub Comments
define variables directly, do not use responsive, such as:
let instances = null const initEditor = () => { instances = CodeMirror.fromTextArea(textarea, options}) }
This is currently feasibleThank you.It works. I have add this demo to the codemirror_demo project