From 31ad317a57ccb75279e3624a030528b897867cc5 Mon Sep 17 00:00:00 2001 From: leo Date: Wed, 18 Dec 2024 17:30:04 +0800 Subject: [PATCH] feature: remember the `Include Untracked Files` toggle state in local changes --- src/Models/RepositorySettings.cs | 6 ++++++ src/ViewModels/Repository.cs | 11 +++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/Models/RepositorySettings.cs b/src/Models/RepositorySettings.cs index 50530c6a..930b31a3 100644 --- a/src/Models/RepositorySettings.cs +++ b/src/Models/RepositorySettings.cs @@ -14,6 +14,12 @@ namespace SourceGit.Models set; } = string.Empty; + public bool IncludeUntrackedInLocalChanges + { + get; + set; + } = true; + public DealWithLocalChanges DealWithLocalChangesOnCheckoutBranch { get; diff --git a/src/ViewModels/Repository.cs b/src/ViewModels/Repository.cs index df6f2e27..66b308b4 100644 --- a/src/ViewModels/Repository.cs +++ b/src/ViewModels/Repository.cs @@ -206,11 +206,15 @@ namespace SourceGit.ViewModels public bool IncludeUntracked { - get => _includeUntracked; + get => _settings.IncludeUntrackedInLocalChanges; set { - if (SetProperty(ref _includeUntracked, value)) + if (value != _settings.IncludeUntrackedInLocalChanges) + { + _settings.IncludeUntrackedInLocalChanges = value; + OnPropertyChanged(); Task.Run(RefreshWorkingCopyChanges); + } } } @@ -918,7 +922,7 @@ namespace SourceGit.ViewModels public void RefreshWorkingCopyChanges() { - var changes = new Commands.QueryLocalChanges(_fullpath, _includeUntracked).Result(); + var changes = new Commands.QueryLocalChanges(_fullpath, _settings.IncludeUntrackedInLocalChanges).Result(); if (_workingCopy == null) return; @@ -2299,7 +2303,6 @@ namespace SourceGit.ViewModels private List _submodules = new List(); private List _visibleSubmodules = new List(); - private bool _includeUntracked = true; private Models.Commit _searchResultSelectedCommit = null; private Timer _autoFetchTimer = null; private DateTime _lastFetchTime = DateTime.MinValue;