Skip to content

Commit 8a5b024

Browse files
committed
fix: gets doubled EOLs while coping content with CRLF line-endings in diff view (#2091)
Signed-off-by: leo <longshuang@msn.cn>
1 parent bf20784 commit 8a5b024

File tree

2 files changed

+4
-17
lines changed

2 files changed

+4
-17
lines changed

src/Native/OS.cs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -116,21 +116,13 @@ public static bool UseSystemWindowFrame
116116
static OS()
117117
{
118118
if (OperatingSystem.IsWindows())
119-
{
120119
_backend = new Windows();
121-
}
122120
else if (OperatingSystem.IsMacOS())
123-
{
124121
_backend = new MacOS();
125-
}
126122
else if (OperatingSystem.IsLinux())
127-
{
128123
_backend = new Linux();
129-
}
130124
else
131-
{
132125
throw new PlatformNotSupportedException();
133-
}
134126
}
135127

136128
public static void SetupDataDir()
@@ -167,11 +159,7 @@ public static bool TestShellOrTerminal(Models.ShellOrTerminal shell)
167159

168160
public static void SetShellOrTerminal(Models.ShellOrTerminal shell)
169161
{
170-
if (shell == null)
171-
ShellOrTerminal = string.Empty;
172-
else
173-
ShellOrTerminal = _backend.FindTerminal(shell);
174-
162+
ShellOrTerminal = shell != null ? _backend.FindTerminal(shell) : string.Empty;
175163
ShellOrTerminalArgs = shell.Args;
176164
}
177165

src/Views/TextDiffView.axaml.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -841,15 +841,14 @@ private async Task CopyWithoutIndicatorsAsync()
841841
// The first selected line (partial selection)
842842
if (i == startIdx && startPosition.Column > 1)
843843
{
844-
builder.Append(line.Content.AsSpan(startPosition.Column - 1));
845-
builder.Append(Environment.NewLine);
844+
builder.Append(line.Content.AsSpan(startPosition.Column - 1)).Append('\n');
846845
continue;
847846
}
848847

849848
// The selection range is larger than original source.
850849
if (i == lines.Count - 1 && i < endIdx)
851850
{
852-
builder.Append(line.Content);
851+
builder.Append(line.Content).Append('\n');
853852
break;
854853
}
855854

@@ -865,7 +864,7 @@ private async Task CopyWithoutIndicatorsAsync()
865864
}
866865

867866
// Other lines.
868-
builder.AppendLine(line.Content);
867+
builder.Append(line.Content).Append('\n');
869868
}
870869

871870
await App.CopyTextAsync(builder.ToString());

0 commit comments

Comments
 (0)