fix: gets doubled EOLs while coping content with CRLF line-endings in diff view (#2091)

Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
leo
2026-02-03 10:28:48 +08:00
parent bf2078477d
commit 8a5b0245b6
2 changed files with 4 additions and 17 deletions

View File

@@ -116,21 +116,13 @@ namespace SourceGit.Native
static OS()
{
if (OperatingSystem.IsWindows())
{
_backend = new Windows();
}
else if (OperatingSystem.IsMacOS())
{
_backend = new MacOS();
}
else if (OperatingSystem.IsLinux())
{
_backend = new Linux();
}
else
{
throw new PlatformNotSupportedException();
}
}
public static void SetupDataDir()
@@ -167,11 +159,7 @@ namespace SourceGit.Native
public static void SetShellOrTerminal(Models.ShellOrTerminal shell)
{
if (shell == null)
ShellOrTerminal = string.Empty;
else
ShellOrTerminal = _backend.FindTerminal(shell);
ShellOrTerminal = shell != null ? _backend.FindTerminal(shell) : string.Empty;
ShellOrTerminalArgs = shell.Args;
}

View File

@@ -841,15 +841,14 @@ namespace SourceGit.Views
// The first selected line (partial selection)
if (i == startIdx && startPosition.Column > 1)
{
builder.Append(line.Content.AsSpan(startPosition.Column - 1));
builder.Append(Environment.NewLine);
builder.Append(line.Content.AsSpan(startPosition.Column - 1)).Append('\n');
continue;
}
// The selection range is larger than original source.
if (i == lines.Count - 1 && i < endIdx)
{
builder.Append(line.Content);
builder.Append(line.Content).Append('\n');
break;
}
@@ -865,7 +864,7 @@ namespace SourceGit.Views
}
// Other lines.
builder.AppendLine(line.Content);
builder.Append(line.Content).Append('\n');
}
await App.CopyTextAsync(builder.ToString());