Skip to content

Commit 70dec95

Browse files
committed
code_review: PR #2494
Since `EscapeForBRE` is only used when selecting item in suggestion popup (and the searching command runs immediately after it), directly call `EscapeForBRE` to generate the searching filter Signed-off-by: leo <longshuang@msn.cn>
1 parent 1e25529 commit 70dec95

2 files changed

Lines changed: 6 additions & 19 deletions

File tree

src/ViewModels/SearchCommitContext.cs

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ public string Filter
2727
get => _filter;
2828
set
2929
{
30-
_isLiteralFilter = false;
3130
if (SetProperty(ref _filter, value))
3231
UpdateSuggestions();
3332
}
@@ -83,14 +82,6 @@ public void ClearFilter()
8382
Results = null;
8483
}
8584

86-
public void SetLiteralFilter(string filter)
87-
{
88-
_isLiteralFilter = true;
89-
_filter = filter;
90-
OnPropertyChanged(nameof(Filter));
91-
UpdateSuggestions();
92-
}
93-
9485
public void ClearSuggestions()
9586
{
9687
Suggestions = null;
@@ -118,9 +109,6 @@ public void StartSearch()
118109
var result = new List<Models.Commit>();
119110
var method = (Models.CommitSearchMethod)_method;
120111
var repoPath = _repo.FullPath;
121-
var filter = (_isLiteralFilter && method == Models.CommitSearchMethod.ByAuthor)
122-
? _filter.EscapeForBRE()
123-
: _filter;
124112

125113
if (method == Models.CommitSearchMethod.BySHA)
126114
{
@@ -143,7 +131,7 @@ public void StartSearch()
143131
}
144132
else if (_onlySearchCurrentBranch)
145133
{
146-
result = await new Commands.QueryCommits(repoPath, filter, method, true)
134+
result = await new Commands.QueryCommits(repoPath, _filter, method, true)
147135
.GetResultAsync()
148136
.ConfigureAwait(false);
149137

@@ -152,7 +140,7 @@ public void StartSearch()
152140
}
153141
else
154142
{
155-
result = await new Commands.QueryCommits(repoPath, filter, method, false)
143+
result = await new Commands.QueryCommits(repoPath, _filter, method, false)
156144
.GetResultAsync()
157145
.ConfigureAwait(false);
158146

@@ -302,7 +290,6 @@ private void UpdateSuggestions()
302290
private int _method = (int)Models.CommitSearchMethod.ByMessage;
303291
private string _filter = string.Empty;
304292
private bool _onlySearchCurrentBranch = false;
305-
private bool _isLiteralFilter = false;
306293
private bool _isQuerying = false;
307294
private List<Models.Commit> _results = null;
308295
private Models.Commit _selected = null;

src/Views/Repository.axaml.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,8 @@ private void OnSearchSuggestionBoxKeyDown(object _, KeyEventArgs e)
327327
}
328328
else if (selected is Models.User user)
329329
{
330-
var apply = user.ToString();
331-
repo.SearchCommitContext.SetLiteralFilter(apply);
330+
var apply = user.ToString().EscapeForBRE();
331+
repo.SearchCommitContext.Filter = apply;
332332
TxtSearchCommitsBox.CaretIndex = apply.Length;
333333
}
334334

@@ -350,8 +350,8 @@ private void OnSearchSuggestionTapped(object sender, TappedEventArgs e)
350350
}
351351
else if (ctx is Models.User user)
352352
{
353-
var apply = user.ToString();
354-
repo.SearchCommitContext.SetLiteralFilter(apply);
353+
var apply = user.ToString().EscapeForBRE();
354+
repo.SearchCommitContext.Filter = apply;
355355
TxtSearchCommitsBox.CaretIndex = apply.Length;
356356
}
357357

0 commit comments

Comments
 (0)