Skip to content

Commit 550493b

Browse files
committed
enhance: prevent requesting worktree files more than once time
Signed-off-by: leo <[email protected]>
1 parent eb18358 commit 550493b

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/ViewModels/Repository.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ public bool IsSearching
294294
SelectedSearchedCommit = null;
295295
SearchCommitFilter = string.Empty;
296296
MatchedFilesForSearching = null;
297+
_requestingWorktreeFiles = false;
297298
_worktreeFiles = null;
298299
}
299300
}
@@ -568,6 +569,7 @@ public void Close()
568569
_searchedCommits.Clear();
569570
_selectedSearchedCommit = null;
570571

572+
_requestingWorktreeFiles = false;
571573
_worktreeFiles = null;
572574
_matchedFilesForSearching = null;
573575
}
@@ -2698,19 +2700,27 @@ private void CalcWorktreeFilesForSearching()
26982700
{
26992701
if (!IsSearchingCommitsByFilePath())
27002702
{
2703+
_requestingWorktreeFiles = false;
27012704
_worktreeFiles = null;
27022705
MatchedFilesForSearching = null;
27032706
GC.Collect();
27042707
return;
27052708
}
27062709

2710+
if (_requestingWorktreeFiles)
2711+
return;
2712+
2713+
_requestingWorktreeFiles = true;
2714+
27072715
Task.Run(() =>
27082716
{
27092717
_worktreeFiles = new Commands.QueryRevisionFileNames(_fullpath, "HEAD").Result();
27102718
Dispatcher.UIThread.Invoke(() =>
27112719
{
2712-
if (IsSearchingCommitsByFilePath())
2720+
if (IsSearchingCommitsByFilePath() && _requestingWorktreeFiles)
27132721
CalcMatchedFilesForSearching();
2722+
2723+
_requestingWorktreeFiles = false;
27142724
});
27152725
});
27162726
}
@@ -2796,6 +2806,7 @@ private void AutoFetchImpl(object sender)
27962806
private string _searchCommitFilter = string.Empty;
27972807
private List<Models.Commit> _searchedCommits = new List<Models.Commit>();
27982808
private Models.Commit _selectedSearchedCommit = null;
2809+
private bool _requestingWorktreeFiles = false;
27992810
private List<string> _worktreeFiles = null;
28002811
private List<string> _matchedFilesForSearching = null;
28012812

0 commit comments

Comments
 (0)