Skip to content

Commit 3bf3afc

Browse files
committed
update action keyword match logic
1 parent e5fbfa2 commit 3bf3afc

File tree

5 files changed

+12
-57
lines changed

5 files changed

+12
-57
lines changed

Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,16 @@ internal async Task<List<Result>> SearchAsync(Query query, CancellationToken tok
6363

6464
private bool ActionKeywordMatch(Query query, string allowedActionKeyword)
6565
{
66-
if (settings.EnabledIndexOnlySearchKeyword && (settings.IndexOnlySearchActionKeyword == Query.GlobalPluginWildcardSign || query.ActionKeyword == allowedActionKeyword))
67-
return true;
66+
if (query.ActionKeyword == settings.IndexOnlySearchActionKeyword)
67+
return settings.IndexOnlySearchActionKeyword == allowedActionKeyword;
6868

69-
if (settings.EnabledPathSearchKeyword && (settings.PathSearchActionKeyword == Query.GlobalPluginWildcardSign || query.ActionKeyword == allowedActionKeyword))
70-
return true;
69+
if (query.ActionKeyword == settings.PathSearchActionKeyword)
70+
return settings.PathSearchActionKeyword == allowedActionKeyword;
7171

72-
return settings.SearchActionKeyword == Query.GlobalPluginWildcardSign || query.ActionKeyword == allowedActionKeyword;
72+
if (query.ActionKeyword == settings.SearchActionKeyword)
73+
return settings.SearchActionKeyword == allowedActionKeyword;
74+
75+
return Query.GlobalPluginWildcardSign == allowedActionKeyword;
7376
}
7477

7578
public async Task<List<Result>> PathSearchAsync(Query query, CancellationToken token = default)

Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ public class Settings
2323

2424
public string PathSearchActionKeyword { get; set; } = Query.GlobalPluginWildcardSign;
2525

26-
public bool EnabledPathSearchKeyword { get; set; }
27-
2826
public string IndexOnlySearchActionKeyword { get; set; } = Query.GlobalPluginWildcardSign;
29-
30-
public bool EnabledIndexOnlySearchKeyword { get; set; }
3127
}
3228
}

Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,15 @@
1616
<Grid.ColumnDefinitions>
1717
<ColumnDefinition Width="180" />
1818
<ColumnDefinition />
19-
<ColumnDefinition />
2019
</Grid.ColumnDefinitions>
2120
<TextBlock Margin="20 10 10 10" FontSize="14" Grid.Row="0" Grid.Column="0" VerticalAlignment="Center"
2221
HorizontalAlignment="Left" Text="Current Action Keyword:" />
2322
<TextBox Name="txtCurrentActionKeyword"
2423
Margin="10" Grid.Row="0" Width="105" Grid.Column="1"
2524
VerticalAlignment="Center"
2625
HorizontalAlignment="Left" />
27-
<CheckBox Name="chkActionKeywordEnabled" Margin="10" Grid.Row="0" Grid.Column="2" Content="Enabled" Width="auto"
28-
VerticalAlignment="Center" Checked="OnActionKeywordEnabledChecked" Unchecked="OnActionKeywordEnabledUnChecked"/>
29-
<StackPanel Orientation="Horizontal" Grid.Column="1" Grid.ColumnSpan="2" Margin="100 92 0 0" Grid.RowSpan="2">
26+
27+
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Grid.Row="1" Grid.Column="1">
3028
<Button Click="OnConfirmButtonClick"
3129
Margin="10 0 10 0" Width="80" Height="35"
3230
Content="OK" />

Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml.cs

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,6 @@ public ActionKeywordSetting(SettingsViewModel settingsViewModel,
3333
txtCurrentActionKeyword.Text = selectedActionKeyword.Keyword;
3434

3535
this.actionKeywordListView = actionKeywordListView;
36-
37-
// Search and File Content action keyword are not allowed to be disabled, they are the default search keywords.
38-
if (currentActionKeyword.KeywordProperty == ActionKeywordProperty.SearchActionKeyword
39-
|| currentActionKeyword.KeywordProperty == ActionKeywordProperty.FileContentSearchActionKeyword)
40-
chkActionKeywordEnabled.Visibility = Visibility.Collapsed;
41-
42-
if (currentActionKeyword.KeywordProperty == ActionKeywordProperty.IndexOnlySearchActionKeyword)
43-
chkActionKeywordEnabled.IsChecked = this.settings.EnabledIndexOnlySearchKeyword;
44-
45-
if (currentActionKeyword.KeywordProperty == ActionKeywordProperty.PathSearchActionKeyword)
46-
chkActionKeywordEnabled.IsChecked = this.settings.EnabledPathSearchKeyword;
4736
}
4837

4938
private void OnConfirmButtonClick(object sender, RoutedEventArgs e)
@@ -88,30 +77,5 @@ private void OnCancelButtonClick(object sender, RoutedEventArgs e)
8877

8978
return;
9079
}
91-
private void OnActionKeywordEnabledChecked(object sender, RoutedEventArgs e)
92-
{
93-
if (currentActionKeyword.KeywordProperty == ActionKeywordProperty.IndexOnlySearchActionKeyword)
94-
settings.EnabledIndexOnlySearchKeyword = true;
95-
96-
if (currentActionKeyword.KeywordProperty == ActionKeywordProperty.PathSearchActionKeyword)
97-
settings.EnabledPathSearchKeyword = true;
98-
}
99-
100-
private void OnActionKeywordEnabledUnChecked(object sender, RoutedEventArgs e)
101-
{
102-
if (currentActionKeyword.Keyword == settings.IndexOnlySearchActionKeyword)
103-
{
104-
settings.EnabledIndexOnlySearchKeyword = false;
105-
// reset to global so it does not take up an action keyword when disabled
106-
settings.IndexOnlySearchActionKeyword = Query.GlobalPluginWildcardSign;
107-
}
108-
109-
if (currentActionKeyword.Keyword == settings.PathSearchActionKeyword)
110-
{
111-
settings.EnabledPathSearchKeyword = false;
112-
// reset to global so it does not take up an action keyword when disabled
113-
settings.PathSearchActionKeyword = Query.GlobalPluginWildcardSign;
114-
}
115-
}
11680
}
11781
}

Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,13 @@ public ExplorerSettings(SettingsViewModel viewModel)
4949
},
5050
new ()
5151
{
52-
Description = viewModel.Settings.EnabledPathSearchKeyword
53-
? viewModel.Context.API.GetTranslation("plugin_explorer_actionkeywordview_path")
54-
: viewModel.Context.API.GetTranslation("plugin_explorer_actionkeywordview_path")
55-
+ " " + viewModel.Context.API.GetTranslation("plugin_explorer_actionkeywordview_brackets_disabled"),
52+
Description = viewModel.Context.API.GetTranslation("plugin_explorer_actionkeywordview_path"),
5653
Keyword = this.viewModel.Settings.PathSearchActionKeyword,
5754
KeywordProperty = ActionKeywordProperty.PathSearchActionKeyword
5855
},
5956
new ()
6057
{
61-
Description = viewModel.Settings.EnabledIndexOnlySearchKeyword
62-
? viewModel.Context.API.GetTranslation("plugin_explorer_actionkeywordview_indexonlysearch")
63-
: viewModel.Context.API.GetTranslation("plugin_explorer_actionkeywordview_indexonlysearch")
64-
+ " " + viewModel.Context.API.GetTranslation("plugin_explorer_actionkeywordview_brackets_disabled"),
58+
Description = viewModel.Context.API.GetTranslation("plugin_explorer_actionkeywordview_indexonlysearch"),
6559
Keyword = this.viewModel.Settings.IndexOnlySearchActionKeyword,
6660
KeywordProperty = ActionKeywordProperty.IndexOnlySearchActionKeyword
6761
}

0 commit comments

Comments
 (0)