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

@ -39,12 +39,12 @@
<!-- AI response -->
<v:AIResponseView Grid.Row="1"
x:Name="TxtResponse"
Margin="8"
Height="320"
BorderThickness="1"
BorderBrush="{DynamicResource Brush.Border2}"
Background="{DynamicResource Brush.Contents}"/>
Background="{DynamicResource Brush.Contents}"
Content="{Binding Text}"/>
<!-- Options -->
<Border Grid.Row="2" Margin="0,0,0,8">

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;