feat(diff): add persisted side-by-side and wrap toggles to the diff viewer
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.IO;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using ClaudeDo.Data.Git;
|
||||
using ClaudeDo.Ui;
|
||||
using ClaudeDo.Ui.Localization;
|
||||
using ClaudeDo.Ui.Services;
|
||||
|
||||
@@ -21,6 +24,7 @@ public sealed partial class DiffViewerViewModel : ViewModelBase
|
||||
{
|
||||
private readonly GitService _git;
|
||||
private readonly IWorkerClient _worker;
|
||||
private readonly AppSettings _settings;
|
||||
|
||||
[ObservableProperty]
|
||||
[NotifyPropertyChangedFor(nameof(IsPlanning))]
|
||||
@@ -56,6 +60,31 @@ public sealed partial class DiffViewerViewModel : ViewModelBase
|
||||
[ObservableProperty] private string _displayedDiff = "";
|
||||
[ObservableProperty] private string? _statusMessage;
|
||||
|
||||
// ── View toggles (persisted to ui.config.json) ──────────────────────────
|
||||
[ObservableProperty] private bool _isSplitView;
|
||||
[ObservableProperty] private bool _wrapLines;
|
||||
|
||||
partial void OnIsSplitViewChanged(bool value)
|
||||
{
|
||||
_settings.DiffViewMode = value ? "split" : "unified";
|
||||
PersistViewPreferences();
|
||||
}
|
||||
|
||||
partial void OnWrapLinesChanged(bool value)
|
||||
{
|
||||
_settings.DiffWrapLines = value;
|
||||
PersistViewPreferences();
|
||||
}
|
||||
|
||||
/// A failed preference write must never take the diff viewer down with it; the toggle
|
||||
/// still works for this session, it just won't survive a restart.
|
||||
private void PersistViewPreferences()
|
||||
{
|
||||
try { _settings.Save(); }
|
||||
catch (IOException) { }
|
||||
catch (UnauthorizedAccessException) { }
|
||||
}
|
||||
|
||||
// ── Planning combined toggle ────────────────────────────────────────────
|
||||
[ObservableProperty] private bool _isCombinedMode;
|
||||
[ObservableProperty] private string? _combinedWarning;
|
||||
@@ -63,10 +92,13 @@ public sealed partial class DiffViewerViewModel : ViewModelBase
|
||||
|
||||
public Action? CloseAction { get; set; }
|
||||
|
||||
public DiffViewerViewModel(GitService git, IWorkerClient worker)
|
||||
public DiffViewerViewModel(GitService git, IWorkerClient worker, AppSettings settings)
|
||||
{
|
||||
_git = git;
|
||||
_worker = worker;
|
||||
_settings = settings;
|
||||
_isSplitView = string.Equals(settings.DiffViewMode, "split", StringComparison.OrdinalIgnoreCase);
|
||||
_wrapLines = settings.DiffWrapLines;
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
|
||||
Reference in New Issue
Block a user