[cmdpal] Fix "copy file path" function in file search extension (#38077)

The original code not work. It will throw com exception.

I prefer to use ClipboardHelper one.

-----

Co-authored-by: Yu Leng (from Dev Box) <yuleng@microsoft.com>
This commit is contained in:
moooyo
2025-03-21 18:35:00 +08:00
committed by GitHub
parent e52dd68fe4
commit 7575c040f8

View File

@@ -5,7 +5,6 @@
using Microsoft.CmdPal.Ext.Indexer.Data; using Microsoft.CmdPal.Ext.Indexer.Data;
using Microsoft.CmdPal.Ext.Indexer.Properties; using Microsoft.CmdPal.Ext.Indexer.Properties;
using Microsoft.CommandPalette.Extensions.Toolkit; using Microsoft.CommandPalette.Extensions.Toolkit;
using Windows.ApplicationModel.DataTransfer;
namespace Microsoft.CmdPal.Ext.Indexer.Commands; namespace Microsoft.CmdPal.Ext.Indexer.Commands;
@@ -24,10 +23,7 @@ internal sealed partial class CopyPathCommand : InvokableCommand
{ {
try try
{ {
var dataPackage = new DataPackage(); ClipboardHelper.SetText(_item.FullPath);
dataPackage.SetText(_item.FullPath);
Clipboard.SetContent(dataPackage);
Clipboard.Flush();
} }
catch catch
{ {