mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Merge pull request #3816 from Flow-Launcher/clipboard_invalid
Use try-catch for query text box paste
This commit is contained in:
commit
b60cca42ce
1 changed files with 17 additions and 7 deletions
|
|
@ -44,6 +44,9 @@ namespace Flow.Launcher
|
||||||
|
|
||||||
#region Private Fields
|
#region Private Fields
|
||||||
|
|
||||||
|
// Class Name
|
||||||
|
private static readonly string ClassName = nameof(MainWindow);
|
||||||
|
|
||||||
// Dependency Injection
|
// Dependency Injection
|
||||||
private readonly Settings _settings;
|
private readonly Settings _settings;
|
||||||
private readonly Theme _theme;
|
private readonly Theme _theme;
|
||||||
|
|
@ -1256,14 +1259,21 @@ namespace Flow.Launcher
|
||||||
|
|
||||||
private void QueryTextBox_OnPaste(object sender, DataObjectPastingEventArgs e)
|
private void QueryTextBox_OnPaste(object sender, DataObjectPastingEventArgs e)
|
||||||
{
|
{
|
||||||
var isText = e.SourceDataObject.GetDataPresent(DataFormats.UnicodeText, true);
|
try
|
||||||
if (isText)
|
|
||||||
{
|
{
|
||||||
var text = e.SourceDataObject.GetData(DataFormats.UnicodeText) as string;
|
var isText = e.SourceDataObject.GetDataPresent(DataFormats.UnicodeText, true);
|
||||||
text = text.Replace(Environment.NewLine, " ");
|
if (isText)
|
||||||
DataObject data = new DataObject();
|
{
|
||||||
data.SetData(DataFormats.UnicodeText, text);
|
var text = e.SourceDataObject.GetData(DataFormats.UnicodeText) as string;
|
||||||
e.DataObject = data;
|
text = text.Replace(Environment.NewLine, " ");
|
||||||
|
DataObject data = new DataObject();
|
||||||
|
data.SetData(DataFormats.UnicodeText, text);
|
||||||
|
e.DataObject = data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
App.API.LogException(ClassName, "Failed to paste text", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue