From fe3a36348ea7cd356660d4bb6ea09099eac8e1da Mon Sep 17 00:00:00 2001 From: leo Date: Thu, 27 May 2021 15:35:45 +0800 Subject: [PATCH] fix: fix crash when diff line is empty --- src/Commands/Diff.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Commands/Diff.cs b/src/Commands/Diff.cs index 6679279f..8be2af51 100644 --- a/src/Commands/Diff.cs +++ b/src/Commands/Diff.cs @@ -36,6 +36,13 @@ namespace SourceGit.Commands { newLine = int.Parse(match.Groups[2].Value); changes.Lines.Add(new Models.TextChanges.Line(Models.TextChanges.LineMode.Indicator, line, "", "")); } else { + if (line.Length == 0) { + changes.Lines.Add(new Models.TextChanges.Line(Models.TextChanges.LineMode.Normal, "", $"{oldLine}", $"{newLine}")); + oldLine++; + newLine++; + return; + } + var ch = line[0]; if (ch == '-') { changes.Lines.Add(new Models.TextChanges.Line(Models.TextChanges.LineMode.Deleted, line.Substring(1), $"{oldLine}", ""));