fix: crash when clipboard is empty

This commit is contained in:
leo 2024-07-01 21:08:37 +08:00
parent 254eac11a1
commit 68abb2d78b
No known key found for this signature in database

View file

@ -128,10 +128,10 @@ namespace SourceGit.Views
else if (e.Key == Key.V && ((OperatingSystem.IsMacOS() && e.KeyModifiers == KeyModifiers.Meta) || (!OperatingSystem.IsMacOS() && e.KeyModifiers == KeyModifiers.Control))) else if (e.Key == Key.V && ((OperatingSystem.IsMacOS() && e.KeyModifiers == KeyModifiers.Meta) || (!OperatingSystem.IsMacOS() && e.KeyModifiers == KeyModifiers.Control)))
{ {
var text = await App.GetClipboardTextAsync(); var text = await App.GetClipboardTextAsync();
text = text.Trim(); if (!string.IsNullOrWhiteSpace(text))
if (!string.IsNullOrEmpty(text))
{ {
text = text.Trim();
if (SubjectEditor.CaretIndex == Subject.Length) if (SubjectEditor.CaretIndex == Subject.Length)
{ {
var idx = text.IndexOf('\n'); var idx = text.IndexOf('\n');