refactor(diff): render planning mode per file and retire DiffLinesView
This commit is contained in:
@@ -3,7 +3,7 @@ using CommunityToolkit.Mvvm.ComponentModel;
|
||||
|
||||
namespace ClaudeDo.Ui.ViewModels.Modals;
|
||||
|
||||
// Shared diff models used by UnifiedDiffParser, DiffLinesView and DiffViewerViewModel.
|
||||
// Shared diff models used by UnifiedDiffParser, DiffTextView and DiffViewerViewModel.
|
||||
|
||||
public enum DiffLineKind { Add, Del, Ctx, File }
|
||||
|
||||
|
||||
@@ -56,7 +56,8 @@ public sealed partial class DiffViewerViewModel : ViewModelBase
|
||||
|
||||
// ── Right pane ──────────────────────────────────────────────────────────
|
||||
[ObservableProperty] private DiffFileViewModel? _selectedFile; // Files mode
|
||||
public ObservableCollection<DiffLineViewModel> DiffLines { get; } = new(); // Planning mode
|
||||
// Planning mode: one entry per file so each gets its own editor and grammar.
|
||||
public ObservableCollection<DiffFileViewModel> PlanningFiles { get; } = new();
|
||||
[ObservableProperty] private string _displayedDiff = "";
|
||||
[ObservableProperty] private string? _statusMessage;
|
||||
|
||||
@@ -250,9 +251,9 @@ public sealed partial class DiffViewerViewModel : ViewModelBase
|
||||
|
||||
partial void OnDisplayedDiffChanged(string value)
|
||||
{
|
||||
DiffLines.Clear();
|
||||
foreach (var line in UnifiedDiffParser.Flatten(UnifiedDiffParser.Parse(value)))
|
||||
DiffLines.Add(line);
|
||||
PlanningFiles.Clear();
|
||||
foreach (var file in UnifiedDiffParser.Parse(value))
|
||||
PlanningFiles.Add(file);
|
||||
}
|
||||
|
||||
// ── Merge (Files mode, branch source) ───────────────────────────────────
|
||||
|
||||
@@ -132,21 +132,6 @@ public static class UnifiedDiffParser
|
||||
return files;
|
||||
}
|
||||
|
||||
/// Flattens multiple parsed files into a single line stream, inserting a
|
||||
/// file-header row before each file so boundaries are visible in a
|
||||
/// single-pane (combined) view.
|
||||
public static List<DiffLineViewModel> Flatten(IEnumerable<DiffFileViewModel> files)
|
||||
{
|
||||
var lines = new List<DiffLineViewModel>();
|
||||
foreach (var file in files)
|
||||
{
|
||||
lines.Add(new DiffLineViewModel { Kind = DiffLineKind.File, Text = file.Path });
|
||||
foreach (var line in file.Lines)
|
||||
lines.Add(line);
|
||||
}
|
||||
return lines;
|
||||
}
|
||||
|
||||
private static void ParseHunkHeader(string header, out int oldStart, out int newStart)
|
||||
{
|
||||
oldStart = 1; newStart = 1;
|
||||
|
||||
Reference in New Issue
Block a user