diff --git a/src/App.axaml.cs b/src/App.axaml.cs index f1676fa3..619ab60c 100644 --- a/src/App.axaml.cs +++ b/src/App.axaml.cs @@ -317,6 +317,18 @@ namespace SourceGit }); } + public static async Task GetClipboardTextAsync() + { + if (Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) + { + if (desktop.MainWindow.Clipboard is { } clipboard) + { + return await clipboard.GetTextAsync(); + } + } + return default; + } + private ResourceDictionary _activeLocale = null; private ResourceDictionary _colorOverrides = null; private Models.INotificationReceiver _notificationReceiver = null; diff --git a/src/ViewModels/Clone.cs b/src/ViewModels/Clone.cs index 7db82081..89eff488 100644 --- a/src/ViewModels/Clone.cs +++ b/src/ViewModels/Clone.cs @@ -56,6 +56,22 @@ namespace SourceGit.ViewModels _page = launcher.ActivePage; View = new Views.Clone() { DataContext = this }; + App.GetClipboardTextAsync() + .ContinueWith(t => + { + if (t.IsFaulted) + { + t.Exception.Handle(static _ => true); + } + else if (t.IsCompleted) + { + var result = t.Result; + if (Models.Remote.IsValidURL(result)) + { + Remote = result; + } + } + }); } public static ValidationResult ValidateRemote(string remote, ValidationContext _)