Merge branch 'sourcegit-scm:develop' into develop

This commit is contained in:
Paolo Ghibaudo 2024-07-01 16:05:07 +02:00 committed by GitHub
commit 9f9b5f2bbb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -20,6 +20,11 @@ namespace SourceGit.Views
protected override Type StyleKeyOverride => typeof(TextBox);
public void Paste(string text)
{
OnTextInput(new TextInputEventArgs() { Text = text });
}
protected override void OnKeyDown(KeyEventArgs e)
{
var dump = new KeyEventArgs()
@ -112,7 +117,7 @@ namespace SourceGit.Views
}
}
private void OnSubjectTextBoxPreviewKeyDown(object sender, KeyEventArgs e)
private async void OnSubjectTextBoxPreviewKeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter || (e.Key == Key.Right && SubjectEditor.CaretIndex == Subject.Length))
{
@ -120,6 +125,36 @@ namespace SourceGit.Views
DescriptionEditor.CaretIndex = 0;
e.Handled = true;
}
else if (e.Key == Key.V && ((OperatingSystem.IsMacOS() && e.KeyModifiers == KeyModifiers.Meta) || (!OperatingSystem.IsMacOS() && e.KeyModifiers == KeyModifiers.Control)))
{
var text = await App.GetClipboardTextAsync();
if (!string.IsNullOrWhiteSpace(text))
{
text = text.Trim();
if (SubjectEditor.CaretIndex == Subject.Length)
{
var idx = text.IndexOf('\n');
if (idx == -1)
{
SubjectEditor.Paste(text);
}
else
{
SubjectEditor.Paste(text.Substring(0, idx));
DescriptionEditor.Focus();
DescriptionEditor.CaretIndex = 0;
DescriptionEditor.Paste(text.Substring(idx + 1) + "\n");
}
}
else
{
SubjectEditor.Paste(text.ReplaceLineEndings(" "));
}
}
e.Handled = true;
}
}
private void OnDescriptionTextBoxPreviewKeyDown(object sender, KeyEventArgs e)