|
2 | 2 | using System.Collections.Generic; |
3 | 3 | using System.IO; |
4 | 4 | using System.Threading.Tasks; |
| 5 | +using Avalonia.Threading; |
5 | 6 | using CommunityToolkit.Mvvm.ComponentModel; |
6 | 7 |
|
7 | 8 | namespace SourceGit.ViewModels |
@@ -191,6 +192,30 @@ public string StagedCountInfo |
191 | 192 | get => string.IsNullOrEmpty(_filter) ? $"({_staged.Count})" : $"({_visibleStaged.Count}/{_staged.Count})"; |
192 | 193 | } |
193 | 194 |
|
| 195 | + public int UnstagedAddedLines |
| 196 | + { |
| 197 | + get => _unstagedAddedLines; |
| 198 | + private set => SetProperty(ref _unstagedAddedLines, value); |
| 199 | + } |
| 200 | + |
| 201 | + public int UnstagedDeletedLines |
| 202 | + { |
| 203 | + get => _unstagedDeletedLines; |
| 204 | + private set => SetProperty(ref _unstagedDeletedLines, value); |
| 205 | + } |
| 206 | + |
| 207 | + public int StagedAddedLines |
| 208 | + { |
| 209 | + get => _stagedAddedLines; |
| 210 | + private set => SetProperty(ref _stagedAddedLines, value); |
| 211 | + } |
| 212 | + |
| 213 | + public int StagedDeletedLines |
| 214 | + { |
| 215 | + get => _stagedDeletedLines; |
| 216 | + private set => SetProperty(ref _stagedDeletedLines, value); |
| 217 | + } |
| 218 | + |
194 | 219 | public ChangeSelection SelectedUnstaged |
195 | 220 | { |
196 | 221 | get => _selectedUnstaged; |
@@ -364,6 +389,29 @@ public void SetData(List<Models.Change> changes) |
364 | 389 |
|
365 | 390 | UpdateInProgressState(); |
366 | 391 | UpdateDetail(); |
| 392 | + |
| 393 | + _ = Task.Run(async () => |
| 394 | + { |
| 395 | + var pref = Preferences.Instance; |
| 396 | + var unstagedStats = await new Commands.QueryDiffLineStats( |
| 397 | + _repo.FullPath, false, pref.IgnoreWhitespaceChangesInDiff, pref.IgnoreCRAtEOLInDiff) |
| 398 | + .GetResultAsync().ConfigureAwait(false); |
| 399 | + var stagedStats = await new Commands.QueryDiffLineStats( |
| 400 | + _repo.FullPath, true, pref.IgnoreWhitespaceChangesInDiff, pref.IgnoreCRAtEOLInDiff) |
| 401 | + .GetResultAsync().ConfigureAwait(false); |
| 402 | + |
| 403 | + Dispatcher.UIThread.Post(() => |
| 404 | + { |
| 405 | + // A newer SetData may have run while fetching stats; drop this stale update. |
| 406 | + if (!ReferenceEquals(_cached, changes)) |
| 407 | + return; |
| 408 | + |
| 409 | + UnstagedAddedLines = unstagedStats.added; |
| 410 | + UnstagedDeletedLines = unstagedStats.deleted; |
| 411 | + StagedAddedLines = stagedStats.added; |
| 412 | + StagedDeletedLines = stagedStats.deleted; |
| 413 | + }); |
| 414 | + }); |
367 | 415 | } |
368 | 416 |
|
369 | 417 | public async Task StageChangesAsync(List<Models.Change> changes, Models.Change next) |
@@ -958,6 +1006,10 @@ public ChangeInTree(Models.Change change) |
958 | 1006 | private List<Models.Change> _visibleStaged = []; |
959 | 1007 | private ChangeSelection _selectedUnstaged = new(null); |
960 | 1008 | private ChangeSelection _selectedStaged = new(null); |
| 1009 | + private int _unstagedAddedLines = 0; |
| 1010 | + private int _unstagedDeletedLines = 0; |
| 1011 | + private int _stagedAddedLines = 0; |
| 1012 | + private int _stagedDeletedLines = 0; |
961 | 1013 | private object _detailContext = null; |
962 | 1014 | private string _filter = string.Empty; |
963 | 1015 | private string _commitMessage = string.Empty; |
|
0 commit comments