From bd91177d3461a8474af3535adf674a1710ee1837 Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Tue, 25 Aug 2020 02:53:38 -0400 Subject: [PATCH] Fixes hasMore being wrong on an edge --- src/git/git.ts | 6 +++--- src/git/parsers/logParser.ts | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/git/git.ts b/src/git/git.ts index d05fe78..385affb 100644 --- a/src/git/git.ts +++ b/src/git/git.ts @@ -689,7 +689,7 @@ export namespace Git { '-m', ]; if (limit && !reverse) { - params.push(`-n${limit}`); + params.push(`-n${limit + 1}`); } if (!merges) { @@ -752,7 +752,7 @@ export namespace Git { ]; if (limit && !reverse) { - params.push(`-n${limit}`); + params.push(`-n${limit + 1}`); } if (skip) { @@ -867,7 +867,7 @@ export namespace Git { '--use-mailmap', ]; if (limit && !useShow) { - params.push(`-n${limit}`); + params.push(`-n${limit + 1}`); } if (skip && !useShow) { params.push(`--skip=${skip}`); diff --git a/src/git/parsers/logParser.ts b/src/git/parsers/logParser.ts index 7036525..9c45360 100644 --- a/src/git/parsers/logParser.ts +++ b/src/git/parsers/logParser.ts @@ -120,7 +120,7 @@ export class GitLogParser { let renamedFileName; let renamedMatch; - while (true) { + loop: while (true) { next = lines.next(); if (next.done) break; @@ -347,6 +347,7 @@ export class GitLogParser { const commit = commits.get(entry.ref!); if (commit === undefined) { i++; + if (limit && i > limit) break loop; } else if (truncationCount) { // Since this matches an existing commit it will be skipped, so reduce our truncationCount to ensure accurate truncation detection truncationCount--; @@ -377,7 +378,7 @@ export class GitLogParser { count: i, limit: limit, range: range, - hasMore: Boolean(truncationCount && i >= truncationCount && truncationCount !== 1), + hasMore: Boolean(truncationCount && i > truncationCount && truncationCount !== 1), }; return log; }