Skip to content

Commit 54ef9c0

Browse files
committed
refactor: use bindings instead of sync manually
1 parent e432559 commit 54ef9c0

File tree

3 files changed

+2
-14
lines changed

3 files changed

+2
-14
lines changed

src/Models/DiffResult.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ public partial class TextDiff
6363
{
6464
public string File { get; set; } = string.Empty;
6565
public List<TextDiffLine> Lines { get; set; } = new List<TextDiffLine>();
66+
public Vector SyncScrollOffset { get; set; } = Vector.Zero;
6667
public int MaxLineNumber = 0;
67-
public Vector SyncScrollOffset = Vector.Zero;
6868

6969
public void GenerateNewPatchFromSelection(Change change, string fileBlobGuid, TextDiffSelection selection, bool revert, string output)
7070
{

src/Views/DiffView.axaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@
224224
<!-- Text Diff -->
225225
<DataTemplate DataType="m:TextDiff">
226226
<v:TextDiffView TextDiff="{Binding}"
227+
SyncScrollOffset="{Binding SyncScrollOffset, Mode=TwoWay}"
227228
UseSideBySideDiff="{Binding Source={x:Static vm:Preference.Instance}, Path=UseSideBySideDiff, Mode=OneWay}"/>
228229
</DataTemplate>
229230

src/Views/TextDiffView.axaml.cs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,19 +1169,11 @@ protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs chang
11691169
if (change.Property == TextDiffProperty)
11701170
{
11711171
if (TextDiff == null)
1172-
{
11731172
Content = null;
1174-
}
11751173
else if (UseSideBySideDiff)
1176-
{
11771174
Content = new ViewModels.TwoSideTextDiff(TextDiff);
1178-
SyncScrollOffset = TextDiff.SyncScrollOffset;
1179-
}
11801175
else
1181-
{
11821176
Content = TextDiff;
1183-
SyncScrollOffset = TextDiff.SyncScrollOffset;
1184-
}
11851177
}
11861178
else if (change.Property == UseSideBySideDiffProperty)
11871179
{
@@ -1194,11 +1186,6 @@ protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs chang
11941186
else
11951187
Content = TextDiff;
11961188
}
1197-
else if (change.Property == SyncScrollOffsetProperty)
1198-
{
1199-
if (TextDiff != null)
1200-
TextDiff.SyncScrollOffset = SyncScrollOffset;
1201-
}
12021189
}
12031190

12041191
private Models.TextDiffSelection GetUnifiedSelection(int startLine, int endLine, bool isOldSide)

0 commit comments

Comments
 (0)