Skip to content

Commit 0384164

Browse files
love-lingerbiancode
authored andcommitted
fix: wrong block ending for added/deleted file
Signed-off-by: leo <[email protected]>
1 parent e820d97 commit 0384164

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
@@ -64,32 +64,32 @@ public BlockNavigation(object context)
6464

6565
var lineIdx = 0;
6666
var blockStartIdx = 0;
67-
var isNewBlock = true;
67+
var isReadingBlock = false;
6868
var blocks = new List<Block>();
6969

7070
foreach (var line in lines)
7171
{
7272
lineIdx++;
7373
if (line.Type is Models.TextDiffLineType.Added or Models.TextDiffLineType.Deleted or Models.TextDiffLineType.None)
7474
{
75-
if (isNewBlock)
75+
if (!isReadingBlock)
7676
{
77-
isNewBlock = false;
77+
isReadingBlock = true;
7878
blockStartIdx = lineIdx;
7979
}
8080
}
8181
else
8282
{
83-
if (!isNewBlock)
83+
if (isReadingBlock)
8484
{
8585
blocks.Add(new Block(blockStartIdx, lineIdx - 1));
86-
isNewBlock = true;
86+
isReadingBlock = false;
8787
}
8888
}
8989
}
9090

91-
if (!isNewBlock)
92-
blocks.Add(new Block(blockStartIdx, lines.Count - 1));
91+
if (isReadingBlock)
92+
blocks.Add(new Block(blockStartIdx, lines.Count));
9393

9494
Blocks.AddRange(blocks);
9595
}

0 commit comments

Comments
 (0)