From b3319b5ec505d5269238a7463c5bfabe84375982 Mon Sep 17 00:00:00 2001 From: Joshua Hurst Date: Mon, 14 Nov 2022 14:04:11 -0800 Subject: [PATCH] Fix issue with end out of range error https://github.com/istanbuljs/v8-to-istanbul/issues/198#issuecomment-1310007608 --- lib/range.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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) {