Skip to content

Commit 1ea69d9

Browse files
committed
enhance: clear search results and suggestions after filter was cleared
Signed-off-by: leo <longshuang@msn.cn>
1 parent 31673a0 commit 1ea69d9

File tree

4 files changed

+14
-12
lines changed

4 files changed

+14
-12
lines changed

src/ViewModels/Repository.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -263,12 +263,12 @@ public bool IncludeUntracked
263263
}
264264
}
265265

266-
public bool IsSearching
266+
public bool IsSearchingCommits
267267
{
268-
get => _isSearching;
268+
get => _isSearchingCommits;
269269
set
270270
{
271-
if (SetProperty(ref _isSearching, value))
271+
if (SetProperty(ref _isSearchingCommits, value))
272272
{
273273
if (value)
274274
SelectedViewIndex = 0;
@@ -1873,7 +1873,7 @@ private void FetchInBackground(object sender)
18731873
private int _localChangesCount = 0;
18741874
private int _stashesCount = 0;
18751875

1876-
private bool _isSearching = false;
1876+
private bool _isSearchingCommits = false;
18771877
private SearchCommitContext _searchCommitContext = null;
18781878

18791879
private string _filter = string.Empty;

src/ViewModels/SearchCommitContext.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ public void Dispose()
8585
public void ClearFilter()
8686
{
8787
Filter = string.Empty;
88+
Selected = null;
89+
Results = null;
8890
}
8991

9092
public void ClearSuggestions()
@@ -158,7 +160,7 @@ public void StartSearch()
158160
{
159161
IsQuerying = false;
160162

161-
if (_repo.IsSearching)
163+
if (_repo.IsSearchingCommits)
162164
Results = result;
163165
});
164166
});
@@ -194,7 +196,7 @@ private void UpdateSuggestions()
194196
{
195197
_requestingWorktreeFiles = false;
196198

197-
if (_repo.IsSearching)
199+
if (_repo.IsSearchingCommits)
198200
{
199201
_worktreeFiles = files;
200202
UpdateSuggestions();

src/Views/Launcher.axaml.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,11 +225,11 @@ protected override async void OnKeyDown(KeyEventArgs e)
225225
e.Handled = true;
226226
return;
227227
case Key.F:
228-
repo.IsSearching = true;
228+
repo.IsSearchingCommits = true;
229229
e.Handled = true;
230230
return;
231231
case Key.H when e.KeyModifiers.HasFlag(KeyModifiers.Shift):
232-
repo.IsSearching = false;
232+
repo.IsSearchingCommits = false;
233233
e.Handled = true;
234234
return;
235235
case Key.P when e.KeyModifiers.HasFlag(KeyModifiers.Shift):

src/Views/Repository.axaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<RadioButton Classes="switch_button"
2424
Width="48"
2525
GroupName="SearchGroup"
26-
IsChecked="{Binding !IsSearching, Mode=OneWay}">
26+
IsChecked="{Binding !IsSearchingCommits, Mode=OneWay}">
2727
<ToolTip.Tip>
2828
<TextBlock>
2929
<Run Text="{DynamicResource Text.Repository.Dashboard}" Foreground="{DynamicResource Brush.FG1}"/>
@@ -37,7 +37,7 @@
3737
<RadioButton Classes="switch_button"
3838
Width="48"
3939
GroupName="SearchGroup"
40-
IsChecked="{Binding IsSearching, Mode=TwoWay}">
40+
IsChecked="{Binding IsSearchingCommits, Mode=TwoWay}">
4141
<ToolTip.Tip>
4242
<TextBlock>
4343
<Run Text="{DynamicResource Text.Repository.Search}" Foreground="{DynamicResource Brush.FG1}"/>
@@ -50,7 +50,7 @@
5050
</StackPanel>
5151

5252
<!-- Dashboard -->
53-
<Grid Grid.Row="1" Margin="0,0,0,8" RowDefinitions="Auto,Auto,*" IsVisible="{Binding !IsSearching}">
53+
<Grid Grid.Row="1" Margin="0,0,0,8" RowDefinitions="Auto,Auto,*" IsVisible="{Binding !IsSearchingCommits}">
5454
<!-- Page Switcher for Right Panel -->
5555
<Border Grid.Row="0" Margin="8,0,4,0" BorderThickness="1" BorderBrush="{DynamicResource Brush.Border2}" CornerRadius="6">
5656
<Border CornerRadius="6" ClipToBounds="True">
@@ -437,7 +437,7 @@
437437
</Grid>
438438

439439
<!-- Commit Search Panel -->
440-
<Grid Grid.Row="1" RowDefinitions="Auto,26,*" Margin="8,0,4,8" IsVisible="{Binding IsSearching}" PropertyChanged="OnSearchCommitPanelPropertyChanged">
440+
<Grid Grid.Row="1" RowDefinitions="Auto,26,*" Margin="8,0,4,8" IsVisible="{Binding IsSearchingCommits}" PropertyChanged="OnSearchCommitPanelPropertyChanged">
441441
<!-- Search Input Box -->
442442
<Grid Grid.Row="0" Height="26" Margin="0,4,0,0">
443443
<TextBox x:Name="TxtSearchCommitsBox"

0 commit comments

Comments
 (0)