thehogfather / brackets-code-folding

Code folding extension for brackets IDE
134 stars 42 forks source link

Exception "Uncaught TypeError: Cannot read property 'textContent' of undefined" #4

Closed MiguelCastillo closed 11 years ago

MiguelCastillo commented 11 years ago

The issue happens with some files... I haven't been able to pin point it to a size or anything, but this file will reproduce the issue.

https://github.com/MiguelCastillo/Brackets-Tern/blob/master/TernReferences.js

Load it up in Brackets and scroll down.

thehogfather commented 11 years ago

I cannot reproduce the error with that file. I'm guessing it is being thrown from line 105?

MiguelCastillo commented 11 years ago

Yeah, my bad. I should provided you with a stack trace. Quick assumption, adding a gutter marker failed and then you try access it anyway.

Uncaught TypeError: Cannot read property 'textContent' of undefined main.js:105 _toggleLineMarker main.js:105 (anonymous function) main.js:126 _decorateGutters main.js:125 _handleScroll main.js:189 f.event.dispatch jquery-1.7.min.js:3 f.event.add.h.handle.i jquery-1.7.min.js:3 f.event.trigger jquery-1.7.min.js:3 f.fn.extend.triggerHandler jquery-1.7.min.js:3 Editor._installEditorListeners._codeMirror.on.self._focused Editor.js:655 signal codemirror.js:5093 (anonymous function)

MiguelCastillo commented 11 years ago

Quick debug and lInfo.gutterMarkers is undefined when the issue occurs... You might want to keep track of your markers yourself and reset them everytime a new document is opened

thehogfather commented 11 years ago

Cool thanks. Although I guess lInfo.gutterMarkers["code-folding-gutter"] must be undefined since there is a condition in the preceding line that checks that lInfo.gutterMarkers is defined (line 104)...?

MiguelCastillo commented 11 years ago

I am using a mousewheel and the issue seems to occur when scrolling kinda fast. If you scroll slow enough, the issue won't happen. So, I am thinking that you are trying to access gutter value before they are created by CodeMirror.

Yeah, you should keep track of you marker manually