diff --git a/lib/range.js b/lib/range.js index 4abdfe78..901722bc 100644 --- a/lib/range.js +++ b/lib/range.js @@ -16,7 +16,7 @@ module.exports.sliceRange = (lines, startCol, endCol, inclusive = false) => { if (startCol >= lines[mid].endCol) { start = mid + 1 } else if (endCol < lines[mid].startCol) { - end = mid - 1 + end = Math.max(mid - 1, start); } else { end = mid while (mid >= 0 && startCol < lines[mid].endCol && endCol >= lines[mid].startCol) {