mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-20 19:55:00 +00:00
enhance: append character U+26D4 to line when \ No newline at end of file
is found in git diff
output (#1197)
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
parent
e9036b5fb9
commit
db46de0261
3 changed files with 28 additions and 10 deletions
|
@ -149,7 +149,8 @@ namespace SourceGit.Commands
|
||||||
|
|
||||||
_oldLine = int.Parse(match.Groups[1].Value);
|
_oldLine = int.Parse(match.Groups[1].Value);
|
||||||
_newLine = int.Parse(match.Groups[2].Value);
|
_newLine = int.Parse(match.Groups[2].Value);
|
||||||
_result.TextDiff.Lines.Add(new Models.TextDiffLine(Models.TextDiffLineType.Indicator, line, 0, 0));
|
_last = new Models.TextDiffLine(Models.TextDiffLineType.Indicator, line, 0, 0);
|
||||||
|
_result.TextDiff.Lines.Add(_last);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -157,7 +158,8 @@ namespace SourceGit.Commands
|
||||||
if (line.Length == 0)
|
if (line.Length == 0)
|
||||||
{
|
{
|
||||||
ProcessInlineHighlights();
|
ProcessInlineHighlights();
|
||||||
_result.TextDiff.Lines.Add(new Models.TextDiffLine(Models.TextDiffLineType.Normal, "", _oldLine, _newLine));
|
_last = new Models.TextDiffLine(Models.TextDiffLineType.Normal, "", _oldLine, _newLine);
|
||||||
|
_result.TextDiff.Lines.Add(_last);
|
||||||
_oldLine++;
|
_oldLine++;
|
||||||
_newLine++;
|
_newLine++;
|
||||||
return;
|
return;
|
||||||
|
@ -173,7 +175,8 @@ namespace SourceGit.Commands
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_deleted.Add(new Models.TextDiffLine(Models.TextDiffLineType.Deleted, line.Substring(1), _oldLine, 0));
|
_last = new Models.TextDiffLine(Models.TextDiffLineType.Deleted, line.Substring(1), _oldLine, 0);
|
||||||
|
_deleted.Add(_last);
|
||||||
_oldLine++;
|
_oldLine++;
|
||||||
}
|
}
|
||||||
else if (ch == '+')
|
else if (ch == '+')
|
||||||
|
@ -185,7 +188,8 @@ namespace SourceGit.Commands
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_added.Add(new Models.TextDiffLine(Models.TextDiffLineType.Added, line.Substring(1), 0, _newLine));
|
_last = new Models.TextDiffLine(Models.TextDiffLineType.Added, line.Substring(1), 0, _newLine);
|
||||||
|
_added.Add(_last);
|
||||||
_newLine++;
|
_newLine++;
|
||||||
}
|
}
|
||||||
else if (ch != '\\')
|
else if (ch != '\\')
|
||||||
|
@ -196,7 +200,8 @@ namespace SourceGit.Commands
|
||||||
{
|
{
|
||||||
_oldLine = int.Parse(match.Groups[1].Value);
|
_oldLine = int.Parse(match.Groups[1].Value);
|
||||||
_newLine = int.Parse(match.Groups[2].Value);
|
_newLine = int.Parse(match.Groups[2].Value);
|
||||||
_result.TextDiff.Lines.Add(new Models.TextDiffLine(Models.TextDiffLineType.Indicator, line, 0, 0));
|
_last = new Models.TextDiffLine(Models.TextDiffLineType.Indicator, line, 0, 0);
|
||||||
|
_result.TextDiff.Lines.Add(_last);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -207,11 +212,16 @@ namespace SourceGit.Commands
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_result.TextDiff.Lines.Add(new Models.TextDiffLine(Models.TextDiffLineType.Normal, line.Substring(1), _oldLine, _newLine));
|
_last = new Models.TextDiffLine(Models.TextDiffLineType.Normal, line.Substring(1), _oldLine, _newLine);
|
||||||
|
_result.TextDiff.Lines.Add(_last);
|
||||||
_oldLine++;
|
_oldLine++;
|
||||||
_newLine++;
|
_newLine++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (line.Equals("\\ No newline at end of file", StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
_last.NoNewLineEndOfFile = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -262,6 +272,7 @@ namespace SourceGit.Commands
|
||||||
private readonly Models.DiffResult _result = new Models.DiffResult();
|
private readonly Models.DiffResult _result = new Models.DiffResult();
|
||||||
private readonly List<Models.TextDiffLine> _deleted = new List<Models.TextDiffLine>();
|
private readonly List<Models.TextDiffLine> _deleted = new List<Models.TextDiffLine>();
|
||||||
private readonly List<Models.TextDiffLine> _added = new List<Models.TextDiffLine>();
|
private readonly List<Models.TextDiffLine> _added = new List<Models.TextDiffLine>();
|
||||||
|
private Models.TextDiffLine _last = null;
|
||||||
private int _oldLine = 0;
|
private int _oldLine = 0;
|
||||||
private int _newLine = 0;
|
private int _newLine = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,7 @@ namespace SourceGit.Models
|
||||||
public int OldLineNumber { get; set; } = 0;
|
public int OldLineNumber { get; set; } = 0;
|
||||||
public int NewLineNumber { get; set; } = 0;
|
public int NewLineNumber { get; set; } = 0;
|
||||||
public List<TextInlineRange> Highlights { get; set; } = new List<TextInlineRange>();
|
public List<TextInlineRange> Highlights { get; set; } = new List<TextInlineRange>();
|
||||||
|
public bool NoNewLineEndOfFile { get; set; } = false;
|
||||||
|
|
||||||
public string OldLine => OldLineNumber == 0 ? string.Empty : OldLineNumber.ToString();
|
public string OldLine => OldLineNumber == 0 ? string.Empty : OldLineNumber.ToString();
|
||||||
public string NewLine => NewLineNumber == 0 ? string.Empty : NewLineNumber.ToString();
|
public string NewLine => NewLineNumber == 0 ? string.Empty : NewLineNumber.ToString();
|
||||||
|
|
|
@ -1253,13 +1253,16 @@ namespace SourceGit.Views
|
||||||
{
|
{
|
||||||
builder.Append(line.Content.Substring(0, 1000));
|
builder.Append(line.Content.Substring(0, 1000));
|
||||||
builder.Append($"...({line.Content.Length - 1000} character trimmed)");
|
builder.Append($"...({line.Content.Length - 1000} character trimmed)");
|
||||||
builder.Append('\n');
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
builder.Append(line.Content);
|
builder.Append(line.Content);
|
||||||
builder.Append('\n');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (line.NoNewLineEndOfFile)
|
||||||
|
builder.Append("\u26D4");
|
||||||
|
|
||||||
|
builder.Append('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
Text = builder.ToString();
|
Text = builder.ToString();
|
||||||
|
@ -1493,13 +1496,16 @@ namespace SourceGit.Views
|
||||||
{
|
{
|
||||||
builder.Append(line.Content.Substring(0, 1000));
|
builder.Append(line.Content.Substring(0, 1000));
|
||||||
builder.Append($"...({line.Content.Length - 1000} characters trimmed)");
|
builder.Append($"...({line.Content.Length - 1000} characters trimmed)");
|
||||||
builder.Append('\n');
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
builder.Append(line.Content);
|
builder.Append(line.Content);
|
||||||
builder.Append('\n');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (line.NoNewLineEndOfFile)
|
||||||
|
builder.Append("\u26D4");
|
||||||
|
|
||||||
|
builder.Append('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
Text = builder.ToString();
|
Text = builder.ToString();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue