diff --git a/lib/utils/linter.js b/lib/utils/linter.js index d33dd07..1555bf8 100644 --- a/lib/utils/linter.js +++ b/lib/utils/linter.js @@ -1,12 +1,18 @@ const getRuleURI = require('eslint-rule-documentation') const generateRange = require('atom-linter').generateRange -function getRange (textEditor, line, col, src, lineStart) { +function getRange (textEditor, line, col, endLine, endCol, src, lineStart) { line = typeof line !== 'undefined' ? parseInt((line - 1) + lineStart, 10) : 0 col = typeof col !== 'undefined' ? parseInt(col - 1, 10) : 0 + endLine = typeof endLine !== 'undefined' ? parseInt((endLine - 1) + lineStart, 10) : null + endCol = typeof endCol !== 'undefined' ? parseInt(endCol - 1, 10) : null src = src || '' src = src.substring(0, col) + if (endLine && endCol) { + return [[line, col], [endLine, endCol]] + } + return generateRange(textEditor, line, col) } @@ -30,7 +36,15 @@ module.exports = function (err, output) { excerpt: msg.message, location: { file: self.filePath, - position: getRange(self.textEditor, msg.line, msg.column, msg.source, self.lineStart) + position: getRange( + self.textEditor, + msg.line, + msg.column, + msg.endLine, + msg.endColumn, + msg.source, + self.lineStart + ) } }