Uncaught TypeError: Cannot read property ‘0’ of null

Edited by @Ben3eeE to include steps to reproduce from #17023 (comment)

  1. Open Atom in safe mode atom --safe
  2. Open a new untitled tab
  3. Change the language mode to HTML
  4. Change line endings to be CRLF
  5. Paste the following contents:
<script type="text/javascript">
  if (Math.abs(resVal - resArrayUpper[lowerBound].resistance) <
      Math.abs(resVal - resArrayUpper[upperBound].resistance)) {
    return lowerBound;
  } else {
    return upperBound;
  }
</script>
  1. Place the cursor on line 7 and try to add a newline

Expected: Atom to add a newline. Editing to work as normal
Actual: This exception is thrown and no newline is added

If you add a whitespace at the end of line 2 editing works as normal

property 0 of null


[Enter steps to reproduce:]

  1. Paste a long line of text in HTML file
  2. Start typing a <p> tag in beginning of this line

Atom: 1.25.0 x64
Electron: 1.7.11
OS: Mac OS X 10.13.3
Thrown From: Atom Core

Stack Trace

Uncaught TypeError: Cannot read property ‘0’ of null

At /Applications/Atom.app/Contents/Resources/app/node_modules/bracket-matcher/lib/tag-finder.js:168

TypeError: Cannot read property '0' of null
    at /Applications/Atom.app/Contents/Resources/app/node_modules/bracket-matcher/lib/tag-finder.js:168:36
    at TextBuffer.module.exports.TextBuffer.scanInRange (/Applications/Atom.app/Contents/Resources/app/node_modules/text-buffer/lib/text-buffer.js:1097:15)
    at TextBuffer.module.exports.TextBuffer.backwardsScanInRange (/Applications/Atom.app/Contents/Resources/app/node_modules/text-buffer/lib/text-buffer.js:1115:25)
    at TextEditor.backwardsScanInBufferRange (/Applications/Atom.app/Contents/Resources/app/src/text-editor.js:3392:82)
    at TagFinder.module.exports.TagFinder.findStartEndTags (/Applications/Atom.app/Contents/Resources/app/node_modules/bracket-matcher/lib/tag-finder.js:163:25)
    at TagFinder.module.exports.TagFinder.findMatchingTags (/Applications/Atom.app/Contents/Resources/app/node_modules/bracket-matcher/lib/tag-finder.js:208:27)
    at BracketMatcherView.module.exports.BracketMatcherView.updateMatch (/Applications/Atom.app/Contents/Resources/app/node_modules/bracket-matcher/lib/bracket-matcher-view.js:135:41)
    at /Applications/Atom.app/Contents/Resources/app/node_modules/bracket-matcher/lib/bracket-matcher-view.js:3:65
    at Function.module.exports.Emitter.simpleDispatch (/Applications/Atom.app/Contents/Resources/app/node_modules/event-kit/lib/emitter.js:25:20)
    at Emitter.module.exports.Emitter.emit (/Applications/Atom.app/Contents/Resources/app/node_modules/event-kit/lib/emitter.js:141:34)
    at TextBuffer.module.exports.TextBuffer.emitDidChangeTextEvent (/Applications/Atom.app/Contents/Resources/app/node_modules/text-buffer/lib/text-buffer.js:1748:32)
    at TextBuffer.module.exports.TextBuffer.transact (/Applications/Atom.app/Contents/Resources/app/node_modules/text-buffer/lib/text-buffer.js:975:18)
    at TextEditor.transact (/Applications/Atom.app/Contents/Resources/app/src/text-editor.js:1839:30)
    at mergeIntersectingSelections (/Applications/Atom.app/Contents/Resources/app/src/text-editor.js:1386:25)
    at TextEditor.mergeSelections (/Applications/Atom.app/Contents/Resources/app/src/text-editor.js:3249:53)
    at TextEditor.mergeIntersectingSelections (/Applications/Atom.app/Contents/Resources/app/src/text-editor.js:3223:42)
    at TextEditor.mutateSelectedText (/Applications/Atom.app/Contents/Resources/app/src/text-editor.js:1385:23)
    at TextEditor.insertText (/Applications/Atom.app/Contents/Resources/app/src/text-editor.js:1349:31)
    at TextEditor.object.(anonymous function) [as insertText] (/Applications/Atom.app/Contents/Resources/app/node_modules/underscore-plus/lib/underscore-plus.js:77:33)
    at TextEditorComponent.didTextInput (/Applications/Atom.app/Contents/Resources/app/src/text-editor-component.js:1654:30)

Commands

     -2:47.9.0 autocomplete-plus:activate (atom-text-editor.editor.is-focused)
  2x -2:45.7.0 core:backspace (input.hidden-input)
     -1:17.5.0 editor:newline (input.hidden-input)
  4x -1:16.5.0 core:move-down (input.hidden-input)
     -1:15.8.0 autocomplete-plus:confirm (input.hidden-input)
     -1:15.8.0 autocomplete-plus:activate (atom-text-editor.editor.is-focused)
  4x -1:14.2.0 core:backspace (input.hidden-input)
     -1:11.7.0 core:save (input.hidden-input)
     -1:05.1.0 core:paste (input.hidden-input)
  2x -0:59 core:move-down (input.hidden-input)
     -0:58.2.0 editor:move-to-end-of-screen-line (input.hidden-input)
     -0:55.8.0 core:backspace (input.hidden-input)
     -0:55.2.0 core:move-down (input.hidden-input)
     -0:54.9.0 core:move-left (input.hidden-input)
     -0:54.3.0 editor:move-to-first-character-of-line (input.hidden-input)
  6x -0:18.5.0 core:backspace (input.hidden-input)

Non-Core Packages

atom-ide-ui 0.9.4 
atom-material-syntax 1.0.8 
atom-material-ui 2.1.3 
city-lights-syntax 1.1.8 
city-lights-ui 1.3.3 
emmet 2.4.3 
ide-python 0.8.2 
ide-typescript 0.7.6 
language-babel 2.84.0 
language-ejs 0.4.0 
language-postcss 1.3.1 
oceanic-next 1.0.0 
teletype 0.10.0 

2 thoughts on “Uncaught TypeError: Cannot read property ‘0’ of null

  1. A million monkeys at a million keyboards won’t reproduce Shakespeare, but they will find bugs in your text editor 😉