Skip to content

Commit be915a2

Browse files
committed
fix: wrong block ending for added/deleted file
Signed-off-by: leo <[email protected]>
1 parent cd80a55 commit be915a2

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/ViewModels/BlockNavigation.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,32 +37,32 @@ public BlockNavigation(List<Models.TextDiffLine> lines)
3737

3838
var lineIdx = 0;
3939
var blockStartIdx = 0;
40-
var isNewBlock = true;
40+
var isReadingBlock = false;
4141
var blocks = new List<Block>();
4242

4343
foreach (var line in lines)
4444
{
4545
lineIdx++;
4646
if (line.Type is Models.TextDiffLineType.Added or Models.TextDiffLineType.Deleted or Models.TextDiffLineType.None)
4747
{
48-
if (isNewBlock)
48+
if (!isReadingBlock)
4949
{
50-
isNewBlock = false;
50+
isReadingBlock = true;
5151
blockStartIdx = lineIdx;
5252
}
5353
}
5454
else
5555
{
56-
if (!isNewBlock)
56+
if (isReadingBlock)
5757
{
5858
blocks.Add(new Block(blockStartIdx, lineIdx - 1));
59-
isNewBlock = true;
59+
isReadingBlock = false;
6060
}
6161
}
6262
}
6363

64-
if (!isNewBlock)
65-
blocks.Add(new Block(blockStartIdx, lines.Count - 1));
64+
if (isReadingBlock)
65+
blocks.Add(new Block(blockStartIdx, lines.Count));
6666

6767
_blocks.AddRange(blocks);
6868
}

0 commit comments

Comments
 (0)