diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 000000000..d69b8462e
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,4 @@
+[*.cs]
+
+# IDE0011: 添加大括号
+csharp_prefer_braces = when_multiline
diff --git a/Flow.Launcher.Test/Flow.Launcher.Test.csproj b/Flow.Launcher.Test/Flow.Launcher.Test.csproj
index 1d0dce5e7..5906e6093 100644
--- a/Flow.Launcher.Test/Flow.Launcher.Test.csproj
+++ b/Flow.Launcher.Test/Flow.Launcher.Test.csproj
@@ -38,6 +38,10 @@
+
+
+
+
diff --git a/Flow.Launcher.sln b/Flow.Launcher.sln
index 21c3b47dc..46c4488a1 100644
--- a/Flow.Launcher.sln
+++ b/Flow.Launcher.sln
@@ -45,6 +45,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Flow.Launcher.Plugin.Url",
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{FFD651C7-0546-441F-BC8C-D4EE8FD01EA7}"
ProjectSection(SolutionItems) = preProject
+ .editorconfig = .editorconfig
.gitattributes = .gitattributes
.gitignore = .gitignore
appveyor.yml = appveyor.yml
diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml
index 9ba0da3f6..3a1a1fb05 100644
--- a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml
+++ b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml
@@ -19,7 +19,8 @@
Quick Access Links
Index Search Excluded Paths
Indexing Options
- Search Activation:
+ Index Search Activation:
+ Path Explore Activation:
File Content Search:
diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Main.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Main.cs
index 8204e755c..92b7c95a0 100644
--- a/Plugins/Flow.Launcher.Plugin.Explorer/Main.cs
+++ b/Plugins/Flow.Launcher.Plugin.Explorer/Main.cs
@@ -28,7 +28,7 @@ namespace Flow.Launcher.Plugin.Explorer
return new ExplorerSettings(viewModel);
}
- public async Task InitAsync(PluginInitContext context)
+ public Task InitAsync(PluginInitContext context)
{
Context = context;
@@ -47,6 +47,8 @@ namespace Flow.Launcher.Plugin.Explorer
contextMenu = new ContextMenu(Context, Settings, viewModel);
searchManager = new SearchManager(Settings, Context);
ResultManager.Init(Context);
+
+ return Task.CompletedTask;
}
public List LoadContextMenus(Result selectedResult)
diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/EnvironmentVariables.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/EnvironmentVariables.cs
index 1e9815cb9..595ac3610 100644
--- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/EnvironmentVariables.cs
+++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/EnvironmentVariables.cs
@@ -10,10 +10,10 @@ namespace Flow.Launcher.Plugin.Explorer.Search
{
internal static bool IsEnvironmentVariableSearch(string search)
{
- return LoadEnvironmentStringPaths().Count > 0
- && search.StartsWith("%")
+ return search.StartsWith("%")
&& search != "%%"
- && !search.Contains("\\");
+ && !search.Contains("\\") &&
+ LoadEnvironmentStringPaths().Count > 0;
}
internal static Dictionary LoadEnvironmentStringPaths()
diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs
index e9b4b0fc1..1cb82b75f 100644
--- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs
+++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs
@@ -39,21 +39,47 @@ namespace Flow.Launcher.Plugin.Explorer.Search
internal async Task> SearchAsync(Query query, CancellationToken token)
{
- var results = new HashSet(PathEqualityComparator.Instance);
-
var querySearch = query.Search;
if (IsFileContentSearch(query.ActionKeyword))
return await WindowsIndexFileContentSearchAsync(query, querySearch, token).ConfigureAwait(false);
+ var result = new HashSet(PathEqualityComparator.Instance);
+
+ if (ActionKeywordMatch(query, settings.PathSearchActionKeyword))
+ {
+ result.UnionWith(await PathSearchAsync(query, token).ConfigureAwait(false));
+ }
+
+ if (ActionKeywordMatch(query, settings.SearchActionKeyword) &&
+ querySearch.Length > 0 &&
+ !querySearch.IsLocationPathString())
+ {
+ result.UnionWith(await WindowsIndexFilesAndFoldersSearchAsync(query, querySearch, token).ConfigureAwait(false));
+ }
+
+ return result.ToList();
+ }
+
+ private bool ActionKeywordMatch(Query query, string actionKeyword)
+ {
+ return query.ActionKeyword == actionKeyword ||
+ query.ActionKeyword.Length == 0 && actionKeyword == Query.GlobalPluginWildcardSign;
+ }
+
+ public async Task> PathSearchAsync(Query query, CancellationToken token = default)
+ {
+ var querySearch = query.Search;
+
// This allows the user to type the assigned action keyword and only see the list of quick folder links
if (string.IsNullOrEmpty(query.Search))
return QuickAccess.AccessLinkListAll(query, settings.QuickAccessLinks);
+ var results = new HashSet(PathEqualityComparator.Instance);
+
var quickaccessLinks = QuickAccess.AccessLinkListMatched(query, settings.QuickAccessLinks);
- if (quickaccessLinks.Count > 0)
- results.UnionWith(quickaccessLinks);
+ results.UnionWith(quickaccessLinks);
var isEnvironmentVariable = EnvironmentVariables.IsEnvironmentVariableSearch(querySearch);
@@ -63,13 +89,6 @@ namespace Flow.Launcher.Plugin.Explorer.Search
// Query is a location path with a full environment variable, eg. %appdata%\somefolder\
var isEnvironmentVariablePath = querySearch[1..].Contains("%\\");
- if (!querySearch.IsLocationPathString() && !isEnvironmentVariablePath)
- {
- results.UnionWith(await WindowsIndexFilesAndFoldersSearchAsync(query, querySearch, token).ConfigureAwait(false));
-
- return results.ToList();
- }
-
var locationPath = querySearch;
if (isEnvironmentVariablePath)
diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs
index a8eac986d..e078bca67 100644
--- a/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs
+++ b/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs
@@ -20,5 +20,7 @@ namespace Flow.Launcher.Plugin.Explorer
public string SearchActionKeyword { get; set; } = Query.GlobalPluginWildcardSign;
public string FileContentSearchActionKeyword { get; set; } = Constants.DefaultContentSearchActionKeyword;
+
+ public string PathSearchActionKeyword { get; set; } = Query.GlobalPluginWildcardSign;
}
}
\ No newline at end of file
diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs b/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs
index 92932bf4c..9d4019b9a 100644
--- a/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs
+++ b/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs
@@ -41,19 +41,36 @@ namespace Flow.Launcher.Plugin.Explorer.ViewModels
Process.Start(psi);
}
- internal void UpdateActionKeyword(string newActionKeyword, string oldActionKeyword)
+ internal void UpdateActionKeyword(ActionKeywordProperty modifiedActionKeyword, string newActionKeyword, string oldActionKeyword)
{
- PluginManager.ReplaceActionKeyword(Context.CurrentPluginMetadata.ID, oldActionKeyword, newActionKeyword);
+ if (Settings.SearchActionKeyword == Settings.PathSearchActionKeyword)
+ PluginManager.AddActionKeyword(Context.CurrentPluginMetadata.ID, newActionKeyword);
+ else
+ PluginManager.ReplaceActionKeyword(Context.CurrentPluginMetadata.ID, oldActionKeyword, newActionKeyword);
- if (Settings.FileContentSearchActionKeyword == oldActionKeyword)
- Settings.FileContentSearchActionKeyword = newActionKeyword;
-
- if (Settings.SearchActionKeyword == oldActionKeyword)
- Settings.SearchActionKeyword = newActionKeyword;
+ switch (modifiedActionKeyword)
+ {
+ case ActionKeywordProperty.SearchActionKeyword:
+ Settings.SearchActionKeyword = newActionKeyword;
+ break;
+ case ActionKeywordProperty.PathSearchActionKeyword:
+ Settings.PathSearchActionKeyword = newActionKeyword;
+ break;
+ case ActionKeywordProperty.FileContentSearchActionKeyword:
+ Settings.FileContentSearchActionKeyword = newActionKeyword;
+ break;
+ }
}
internal bool IsActionKeywordAlreadyAssigned(string newActionKeyword) => PluginManager.ActionKeywordRegistered(newActionKeyword);
internal bool IsNewActionKeywordGlobal(string newActionKeyword) => newActionKeyword == Query.GlobalPluginWildcardSign;
}
+
+ public enum ActionKeywordProperty
+ {
+ SearchActionKeyword,
+ PathSearchActionKeyword,
+ FileContentSearchActionKeyword
+ }
}
diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml.cs
index 2957283ad..d1040f746 100644
--- a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml.cs
+++ b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml.cs
@@ -23,6 +23,7 @@ namespace Flow.Launcher.Plugin.Explorer.Views
private ActionKeywordView currentActionKeyword;
+
private List actionKeywordListView;
public ActionKeywordSetting(SettingsViewModel settingsViewModel, List actionKeywordListView, ActionKeywordView selectedActionKeyword)
@@ -35,7 +36,7 @@ namespace Flow.Launcher.Plugin.Explorer.Views
txtCurrentActionKeyword.Text = selectedActionKeyword.Keyword;
- this.actionKeywordListView = actionKeywordListView;
+ this.actionKeywordListView = actionKeywordListView;
}
private void OnConfirmButtonClick(object sender, RoutedEventArgs e)
@@ -52,20 +53,19 @@ namespace Flow.Launcher.Plugin.Explorer.Views
return;
}
- if (settingsViewModel.IsNewActionKeywordGlobal(newActionKeyword)
- && currentActionKeyword.Description
- == settingsViewModel.Context.API.GetTranslation("plugin_explorer_actionkeywordview_filecontentsearch"))
+ if (settingsViewModel.IsNewActionKeywordGlobal(newActionKeyword)
+ && currentActionKeyword.KeywordProperty == ActionKeywordProperty.FileContentSearchActionKeyword)
{
MessageBox.Show(settingsViewModel.Context.API.GetTranslation("plugin_explorer_globalActionKeywordInvalid"));
return;
}
-
+
if (!settingsViewModel.IsActionKeywordAlreadyAssigned(newActionKeyword))
{
- settingsViewModel.UpdateActionKeyword(newActionKeyword, currentActionKeyword.Keyword);
+ settingsViewModel.UpdateActionKeyword(currentActionKeyword.KeywordProperty, newActionKeyword, currentActionKeyword.Keyword);
- actionKeywordListView.Where(x => x.Description == currentActionKeyword.Description).FirstOrDefault().Keyword = newActionKeyword;
+ actionKeywordListView.FirstOrDefault(x => x.Description == currentActionKeyword.Description).Keyword = newActionKeyword;
Close();
diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml
index b4795ec8b..ce6dbba36 100644
--- a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml
+++ b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml
@@ -24,7 +24,7 @@
Margin="0,5,0,0" />
+ Margin="250,5,0,0" />
diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml.cs
index 26f169c92..b8c9a605a 100644
--- a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml.cs
+++ b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml.cs
@@ -35,16 +35,24 @@ namespace Flow.Launcher.Plugin.Explorer.Views
actionKeywordsListView = new List
{
- new ActionKeywordView()
- {
- Description = viewModel.Context.API.GetTranslation("plugin_explorer_actionkeywordview_search"),
- Keyword = this.viewModel.Settings.SearchActionKeyword
- },
- new ActionKeywordView()
- {
- Description = viewModel.Context.API.GetTranslation("plugin_explorer_actionkeywordview_filecontentsearch"),
- Keyword = this.viewModel.Settings.FileContentSearchActionKeyword
- }
+ new ()
+ {
+ Description = viewModel.Context.API.GetTranslation("plugin_explorer_actionkeywordview_search"),
+ Keyword = this.viewModel.Settings.SearchActionKeyword,
+ KeywordProperty = ActionKeywordProperty.SearchActionKeyword
+ },
+ new ()
+ {
+ Description = viewModel.Context.API.GetTranslation("plugin_explorer_actionkeywordview_filecontentsearch"),
+ Keyword = this.viewModel.Settings.FileContentSearchActionKeyword,
+ KeywordProperty = ActionKeywordProperty.FileContentSearchActionKeyword
+ },
+ new ()
+ {
+ Description = viewModel.Context.API.GetTranslation("plugin_explorer_actionkeywordview_path"),
+ Keyword = this.viewModel.Settings.PathSearchActionKeyword,
+ KeywordProperty = ActionKeywordProperty.PathSearchActionKeyword
+ }
};
lbxActionKeywords.ItemsSource = actionKeywordsListView;
@@ -71,7 +79,7 @@ namespace Flow.Launcher.Plugin.Explorer.Views
&& btnEdit.Visibility == Visibility.Hidden)
btnEdit.Visibility = Visibility.Visible;
- if ((lbxAccessLinks.Items.Count == 0 && lbxExcludedPaths.Items.Count == 0)
+ if (lbxAccessLinks.Items.Count == 0 && lbxExcludedPaths.Items.Count == 0
&& btnDelete.Visibility == Visibility.Visible
&& btnEdit.Visibility == Visibility.Visible)
{
@@ -122,7 +130,7 @@ namespace Flow.Launcher.Plugin.Explorer.Views
private void expActionKeywords_Collapsed(object sender, RoutedEventArgs e)
{
if (!expActionKeywords.IsExpanded)
- expActionKeywords.Height = Double.NaN;
+ expActionKeywords.Height = double.NaN;
}
private void expAccessLinks_Click(object sender, RoutedEventArgs e)
@@ -135,20 +143,20 @@ namespace Flow.Launcher.Plugin.Explorer.Views
if (expActionKeywords.IsExpanded)
expActionKeywords.IsExpanded = false;
-
+
RefreshView();
}
private void expAccessLinks_Collapsed(object sender, RoutedEventArgs e)
{
if (!expAccessLinks.IsExpanded)
- expAccessLinks.Height = Double.NaN;
+ expAccessLinks.Height = double.NaN;
}
private void expExcludedPaths_Click(object sender, RoutedEventArgs e)
{
if (expExcludedPaths.IsExpanded)
- expAccessLinks.Height = Double.NaN;
+ expAccessLinks.Height = double.NaN;
if (expAccessLinks.IsExpanded)
expAccessLinks.IsExpanded = false;
@@ -161,7 +169,7 @@ namespace Flow.Launcher.Plugin.Explorer.Views
private void btnDelete_Click(object sender, RoutedEventArgs e)
{
- var selectedRow = lbxAccessLinks.SelectedItem as AccessLink?? lbxExcludedPaths.SelectedItem as AccessLink;
+ var selectedRow = lbxAccessLinks.SelectedItem as AccessLink ?? lbxExcludedPaths.SelectedItem as AccessLink;
if (selectedRow != null)
{
@@ -315,6 +323,7 @@ namespace Flow.Launcher.Plugin.Explorer.Views
{
public string Description { get; set; }
+ public ActionKeywordProperty KeywordProperty { get; init; }
public string Keyword { get; set; }
}
}