Skip to content

Commit

Permalink
Only try to display messages from valid lines
Browse files Browse the repository at this point in the history
Attempting to prevent the following exception:

    Uncaught Error: No screen line exists when converting buffer row to screen row /Applications/Atom.app/Contents/Resources/app/src/display-buffer.js:932
      module.exports.DisplayBuffer.screenPositionForBufferPosition /Applications/Atom.app/Contents/Resources/app/src/display-buffer.js:932
      module.exports.Marker.getHeadScreenPosition /Applications/Atom.app/Contents/Resources/app/src/marker.js:211
      Marker /Applications/Atom.app/Contents/Resources/app/src/marker.js:45
      module.exports.DisplayBuffer.getMarker /Applications/Atom.app/Contents/Resources/app/src/display-buffer.js:1124
      module.exports.DisplayBuffer.markBufferRange /Applications/Atom.app/Contents/Resources/app/src/display-buffer.js:1156
      module.exports.Editor.markBufferRange /Applications/Atom.app/Contents/Resources/app/src/editor.js:1186
      LinterView.display linter-view.coffee:180
      LinterView.processMessage linter-view.coffee:159
      (anonymous function) linter-view.coffee:1
      (anonymous function) linter-view.coffee:142
      Linter.processMessage linter.coffee:150
      (anonymous function) linter.coffee:127
      BufferedProcess.triggerExitCallback /Applications/Atom.app/Contents/Resources/app/src/buffered-process.js:52
      (anonymous function) /Applications/Atom.app/Contents/Resources/app/src/buffered-process.js:59
      (anonymous function) /Applications/Atom.app/Contents/Resources/app/src/buffered-process.js:105
      EventEmitter.emit events.js:129
      (anonymous function) net.js:461

Test Plan:
Crossed fingers
  • Loading branch information
dmnd committed Sep 20, 2014
1 parent 3a221f8 commit c3e7572
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/linter.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class Linter
messages = []
regex = XRegExp @regex, @regexFlags
XRegExp.forEach message, regex, (match, i) =>
messages.push(@createMessage(match))
messages.push(m) if m = @createMessage(match)
, this
callback messages

Expand Down Expand Up @@ -229,6 +229,13 @@ class Linter
rowStart = decrementParse match.lineStart ? match.line
rowEnd = decrementParse match.lineEnd ? match.line

# if this message purports to be from beyond the maximum line count,
# ignore it
maxRow = rowEnd ? rowStart
if maxRow > @editor.getLineCount()
log "ignoring #{match} - it's longer than the buffer"
return null

match.col ?= 0
unless match.colStart
position = new Point(rowStart, match.col)
Expand Down

0 comments on commit c3e7572

Please sign in to comment.