Skip to content

Commit be3f418

Browse files
committed
fix: no diff content shows with new files (#1193)
Signed-off-by: leo <[email protected]>
1 parent a97f163 commit be3f418

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

src/Commands/Diff.cs

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,6 @@ public Diff(string repo, Models.DiffOption opt, int unified, bool ignoreWhitespa
3636
public Models.DiffResult Result()
3737
{
3838
var rs = ReadToEnd();
39-
if (!rs.IsSuccess)
40-
{
41-
_result.TextDiff = null;
42-
return _result;
43-
}
44-
4539
var start = 0;
4640
var end = rs.StdOut.IndexOf('\n', start);
4741
while (end > 0)
@@ -56,19 +50,15 @@ public Models.DiffResult Result()
5650
if (start < rs.StdOut.Length)
5751
ParseLine(rs.StdOut.Substring(start));
5852

59-
if (_result.IsBinary || _result.IsLFS)
53+
if (_result.IsBinary || _result.IsLFS || _result.TextDiff.Lines.Count == 0)
6054
{
6155
_result.TextDiff = null;
6256
}
6357
else
6458
{
6559
ProcessInlineHighlights();
66-
67-
if (_result.TextDiff.Lines.Count == 0)
68-
_result.TextDiff = null;
69-
else
70-
_result.TextDiff.MaxLineNumber = Math.Max(_newLine, _oldLine);
71-
}
60+
_result.TextDiff.MaxLineNumber = Math.Max(_newLine, _oldLine);
61+
}
7262

7363
return _result;
7464
}

0 commit comments

Comments
 (0)