From e143abd9d191f9a51febe3bcffe1dbd3961db27d Mon Sep 17 00:00:00 2001 From: Julian Bildner Date: Sat, 26 Mar 2022 13:29:51 +0100 Subject: [PATCH] Fix blob doesn't get rendered if todo is in last line of a file --- dist/index.js | 11 +++-------- src/TodoDetails.ts | 10 +++------- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/dist/index.js b/dist/index.js index eff66c2..d3a6223 100644 --- a/dist/index.js +++ b/dist/index.js @@ -593,18 +593,13 @@ function getFileBoundaries(changes, line, paddingTop = 0, paddingBottom = 2) { const lastChangedLine = lastChange.ln || lastChange.ln2; let start; if (line == firstChangedLine) { - start = Math.max(0, line - paddingTop); + start = Math.max(1, line - paddingTop); } else { start = Math.max(line - paddingTop, firstChangedLine); } - let end; - if (line == lastChangedLine) { - end = line + paddingBottom; - } - else { - end = Math.min(line + paddingBottom, lastChangedLine); - } + // we dont know the actual lines count of the file, so we cant add something like minPadding (at least for the bottom) + let end = Math.min(line + paddingBottom, lastChangedLine); return { start, end }; } /** diff --git a/src/TodoDetails.ts b/src/TodoDetails.ts index d069db8..dd20730 100644 --- a/src/TodoDetails.ts +++ b/src/TodoDetails.ts @@ -21,17 +21,13 @@ function getFileBoundaries(changes: any[], line: number, paddingTop = 0, padding let start; if(line == firstChangedLine){ - start = Math.max(0, line - paddingTop); + start = Math.max(1, line - paddingTop); } else { start = Math.max(line - paddingTop, firstChangedLine) } - let end; - if(line == lastChangedLine) { - end = line + paddingBottom; - } else { - end = Math.min(line + paddingBottom, lastChangedLine) - } + // we dont know the actual lines count of the file, so we cant add something like minPadding (at least for the bottom) + let end = Math.min(line + paddingBottom, lastChangedLine) return {start, end} }