Skip to content

Commit 9c153bd

Browse files
committed
Switch to WinForms for clipboard
Some windows skus don't have WPF but do include winforms, so switch to winforms to access the clipboard.
1 parent 9a85eed commit 9c153bd

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

PSReadLine/KillYank.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
using System.Collections.Generic;
77
using System.Diagnostics.CodeAnalysis;
88
using System.Management.Automation.Language;
9-
using System.Windows;
9+
using System.Windows.Forms;
1010

1111
namespace Microsoft.PowerShell
1212
{
@@ -517,7 +517,10 @@ public static void Copy(ConsoleKeyInfo? key = null, object arg = null)
517517
{
518518
textToSet = _singleton._buffer.ToString();
519519
}
520-
ExecuteOnSTAThread(() => Clipboard.SetText(textToSet));
520+
if (!string.IsNullOrEmpty(textToSet))
521+
{
522+
ExecuteOnSTAThread(() => Clipboard.SetText(textToSet));
523+
}
521524
}
522525

523526
/// <summary>

PSReadLine/PSReadLine.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@
3535
<Prefer32Bit>false</Prefer32Bit>
3636
</PropertyGroup>
3737
<ItemGroup>
38-
<Reference Include="PresentationCore" />
3938
<Reference Include="System" />
4039
<Reference Include="System.Core" />
4140
<Reference Include="System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
4241
<SpecificVersion>False</SpecificVersion>
4342
<HintPath>C:\Program Files (x86)\Reference Assemblies\Microsoft\WindowsPowerShell\3.0\System.Management.Automation.dll</HintPath>
4443
</Reference>
44+
<Reference Include="System.Windows.Forms" />
4545
<Reference Include="System.Xml.Linq" />
4646
<Reference Include="System.Data.DataSetExtensions" />
4747
<Reference Include="Microsoft.CSharp" />

PSReadLine/ScreenCapture.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
using System;
66
using System.Diagnostics.CodeAnalysis;
77
using System.Text;
8-
using System.Windows;
8+
using System.Windows.Forms;
99

1010
namespace Microsoft.PowerShell
1111
{

0 commit comments

Comments
 (0)