refactor: rewrite the way reading full message of commit
Some checks are pending
Continuous Integration / Build (push) Waiting to run
Continuous Integration / Prepare version string (push) Waiting to run
Continuous Integration / Package (push) Blocked by required conditions

This commit is contained in:
leo 2024-12-13 11:00:03 +08:00
parent a99bd2e973
commit 751991c816
No known key found for this signature in database
2 changed files with 11 additions and 8 deletions

View file

@ -52,28 +52,31 @@ namespace SourceGit.Commands
_current.Commit.CommitterTime = ulong.Parse(line); _current.Commit.CommitterTime = ulong.Parse(line);
break; break;
default: default:
if (line.Equals(_boundary, StringComparison.Ordinal)) var boundary = rs.StdOut.IndexOf(_boundary, end + 1);
if (boundary > end)
{ {
nextPartIdx = -1; _current.Message = rs.StdOut.Substring(start, boundary - start - 1);
_current.Message = _current.Message.Trim(); end = boundary + _boundary.Length;
} }
else else
{ {
_current.Message = _current.Message + "\n" + line; _current.Message = rs.StdOut.Substring(start);
end = rs.StdOut.Length - 2;
} }
nextPartIdx = -1;
break; break;
} }
nextPartIdx++; nextPartIdx++;
start = end + 1; start = end + 1;
if (start >= rs.StdOut.Length - 1)
break;
end = rs.StdOut.IndexOf('\n', start); end = rs.StdOut.IndexOf('\n', start);
} }
if (_current != null)
_current.Message = _current.Message.Trim();
return _commits; return _commits;
} }

View file

@ -95,7 +95,7 @@ namespace SourceGit.Views
if (change.Property == TextProperty && _changingWay == TextChangeWay.None) if (change.Property == TextProperty && _changingWay == TextChangeWay.None)
{ {
_changingWay = TextChangeWay.FromSource; _changingWay = TextChangeWay.FromSource;
var normalized = Text.ReplaceLineEndings("\n").Trim(); var normalized = Text.ReplaceLineEndings("\n");
var subjectEnd = normalized.IndexOf("\n\n", StringComparison.Ordinal); var subjectEnd = normalized.IndexOf("\n\n", StringComparison.Ordinal);
if (subjectEnd == -1) if (subjectEnd == -1)
{ {