fix: empty dialog when generating commit message with AI (#1257)

Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
leo 2025-04-29 09:14:24 +08:00
parent 226bc434f5
commit 5681bf489d
No known key found for this signature in database
2 changed files with 21 additions and 2 deletions

View file

@ -15,6 +15,15 @@ namespace SourceGit.Views
{
public class AIResponseView : TextEditor
{
public static readonly StyledProperty<string> ContentProperty =
AvaloniaProperty.Register<AIResponseView, string>(nameof(Content), string.Empty);
public string Content
{
get => GetValue(ContentProperty);
set => SetValue(ContentProperty, value);
}
protected override Type StyleKeyOverride => typeof(TextEditor);
public AIResponseView() : base(new TextArea(), new TextDocument())
@ -58,6 +67,16 @@ namespace SourceGit.Views
GC.Collect();
}
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
{
base.OnPropertyChanged(change);
if (change.Property == ContentProperty)
{
Text = Content;
}
}
private void OnTextViewContextRequested(object sender, ContextRequestedEventArgs e)
{
var selected = SelectedText;