Skip to content

Commit 7b3f87c

Browse files
committed
enhance: keep navigation state after switch view mode in text diff view (#1952)
Signed-off-by: leo <longshuang@msn.cn>
1 parent 646b080 commit 7b3f87c

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/ViewModels/DiffContext.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,9 +273,9 @@ private void LoadContent()
273273
IsTextDiff = true;
274274

275275
if (Preferences.Instance.UseSideBySideDiff)
276-
Content = new TwoSideTextDiff(_option, cur, _content as TwoSideTextDiff);
276+
Content = new TwoSideTextDiff(_option, cur, _content as TextDiffContext);
277277
else
278-
Content = new CombinedTextDiff(_option, cur, _content as CombinedTextDiff);
278+
Content = new CombinedTextDiff(_option, cur, _content as TextDiffContext);
279279
}
280280
else
281281
{

src/ViewModels/TextDiffContext.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ protected void TryKeepPrevState(TextDiffContext prev, List<Models.TextDiffLine>
167167

168168
public class CombinedTextDiff : TextDiffContext
169169
{
170-
public CombinedTextDiff(Models.DiffOption option, Models.TextDiff diff, CombinedTextDiff previous = null)
170+
public CombinedTextDiff(Models.DiffOption option, Models.TextDiff diff, TextDiffContext previous = null)
171171
{
172172
_option = option;
173173
_data = diff;
@@ -177,7 +177,7 @@ public CombinedTextDiff(Models.DiffOption option, Models.TextDiff diff, Combined
177177

178178
public override TextDiffContext SwitchMode()
179179
{
180-
return new TwoSideTextDiff(_option, _data);
180+
return new TwoSideTextDiff(_option, _data, this);
181181
}
182182
}
183183

@@ -186,7 +186,7 @@ public class TwoSideTextDiff : TextDiffContext
186186
public List<Models.TextDiffLine> Old { get; } = [];
187187
public List<Models.TextDiffLine> New { get; } = [];
188188

189-
public TwoSideTextDiff(Models.DiffOption option, Models.TextDiff diff, TwoSideTextDiff previous = null)
189+
public TwoSideTextDiff(Models.DiffOption option, Models.TextDiff diff, TextDiffContext previous = null)
190190
{
191191
_option = option;
192192
_data = diff;
@@ -220,7 +220,7 @@ public override bool IsSideBySide()
220220

221221
public override TextDiffContext SwitchMode()
222222
{
223-
return new CombinedTextDiff(_option, _data);
223+
return new CombinedTextDiff(_option, _data, this);
224224
}
225225

226226
public void ConvertsToCombinedRange(ref int startLine, ref int endLine, bool isOldSide)

0 commit comments

Comments
 (0)