Skip to content

Commit 7da7e60

Browse files
authored
Merge branch 'dev' into add_nodejs_env
2 parents ae66a2c + efbc588 commit 7da7e60

File tree

7 files changed

+166
-14
lines changed

7 files changed

+166
-14
lines changed

Flow.Launcher.Infrastructure/Flow.Launcher.Infrastructure.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
<PrivateAssets>all</PrivateAssets>
5454
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
5555
</PackageReference>
56-
<PackageReference Include="Microsoft.VisualStudio.Threading" Version="17.3.44" />
56+
<PackageReference Include="Microsoft.VisualStudio.Threading" Version="17.4.27" />
5757
<PackageReference Include="NLog" Version="4.7.10" />
5858
<PackageReference Include="NLog.Schema" Version="4.7.10" />
5959
<PackageReference Include="NLog.Web.AspNetCore" Version="4.13.0" />

Flow.Launcher.Test/Plugins/ExplorerTest.cs

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,5 +269,129 @@ public void GivenDirectoryInfoSearch_WhenSearchPatternHotKeyIsSearchAll_ThenSear
269269
// Then
270270
Assert.AreEqual(expectedString, resultString);
271271
}
272+
273+
[TestCase("c:\\somefolder\\someotherfolder", ResultType.Folder, "irrelevant", false, true, "c:\\somefolder\\someotherfolder\\")]
274+
[TestCase("c:\\somefolder\\someotherfolder\\", ResultType.Folder, "irrelevant", true, true, "c:\\somefolder\\someotherfolder\\")]
275+
[TestCase("c:\\somefolder\\someotherfolder", ResultType.Folder, "irrelevant", true, false, "p c:\\somefolder\\someotherfolder\\")]
276+
[TestCase("c:\\somefolder\\someotherfolder\\", ResultType.Folder, "irrelevant", false, false, "c:\\somefolder\\someotherfolder\\")]
277+
[TestCase("c:\\somefolder\\someotherfolder", ResultType.Folder, "p", true, false, "p c:\\somefolder\\someotherfolder\\")]
278+
[TestCase("c:\\somefolder\\someotherfolder", ResultType.Folder, "", true, true, "c:\\somefolder\\someotherfolder\\")]
279+
public void GivenFolderResult_WhenGetPath_ThenPathShouldBeExpectedString(
280+
string path,
281+
ResultType type,
282+
string actionKeyword,
283+
bool pathSearchKeywordEnabled,
284+
bool searchActionKeywordEnabled,
285+
string expectedResult)
286+
{
287+
// Given
288+
var settings = new Settings()
289+
{
290+
PathSearchKeywordEnabled = pathSearchKeywordEnabled,
291+
PathSearchActionKeyword = "p",
292+
SearchActionKeywordEnabled = searchActionKeywordEnabled,
293+
SearchActionKeyword = Query.GlobalPluginWildcardSign
294+
};
295+
ResultManager.Init(new PluginInitContext(), settings);
296+
297+
// When
298+
var result = ResultManager.GetPathWithActionKeyword(path, type, actionKeyword);
299+
300+
// Then
301+
Assert.AreEqual(result, expectedResult);
302+
}
303+
304+
[TestCase("c:\\somefolder\\somefile", ResultType.File, "irrelevant", false, true, "e c:\\somefolder\\somefile")]
305+
[TestCase("c:\\somefolder\\somefile", ResultType.File, "p", true, false, "p c:\\somefolder\\somefile")]
306+
[TestCase("c:\\somefolder\\somefile", ResultType.File, "e", true, true, "e c:\\somefolder\\somefile")]
307+
[TestCase("c:\\somefolder\\somefile", ResultType.File, "irrelevant", false, false, "e c:\\somefolder\\somefile")]
308+
public void GivenFileResult_WhenGetPath_ThenPathShouldBeExpectedString(
309+
string path,
310+
ResultType type,
311+
string actionKeyword,
312+
bool pathSearchKeywordEnabled,
313+
bool searchActionKeywordEnabled,
314+
string expectedResult)
315+
{
316+
// Given
317+
var settings = new Settings()
318+
{
319+
PathSearchKeywordEnabled = pathSearchKeywordEnabled,
320+
PathSearchActionKeyword = "p",
321+
SearchActionKeywordEnabled = searchActionKeywordEnabled,
322+
SearchActionKeyword = "e"
323+
};
324+
ResultManager.Init(new PluginInitContext(), settings);
325+
326+
// When
327+
var result = ResultManager.GetPathWithActionKeyword(path, type, actionKeyword);
328+
329+
// Then
330+
Assert.AreEqual(result, expectedResult);
331+
}
332+
333+
[TestCase("somefolder", "c:\\somefolder\\", ResultType.Folder, "q", false, false, "q somefolder")]
334+
[TestCase("somefolder", "c:\\somefolder\\", ResultType.Folder, "i", true, false, "p c:\\somefolder\\")]
335+
[TestCase("somefolder", "c:\\somefolder\\", ResultType.Folder, "irrelevant", true, true, "c:\\somefolder\\")]
336+
public void GivenQueryWithFolderTypeResult_WhenGetAutoComplete_ThenResultShouldBeExpectedString(
337+
string title,
338+
string path,
339+
ResultType resultType,
340+
string actionKeyword,
341+
bool pathSearchKeywordEnabled,
342+
bool searchActionKeywordEnabled,
343+
string expectedResult)
344+
{
345+
// Given
346+
var query = new Query() { ActionKeyword = actionKeyword };
347+
var settings = new Settings()
348+
{
349+
PathSearchKeywordEnabled = pathSearchKeywordEnabled,
350+
PathSearchActionKeyword = "p",
351+
SearchActionKeywordEnabled = searchActionKeywordEnabled,
352+
SearchActionKeyword = Query.GlobalPluginWildcardSign,
353+
QuickAccessActionKeyword = "q",
354+
IndexSearchActionKeyword = "i"
355+
};
356+
ResultManager.Init(new PluginInitContext(), settings);
357+
358+
// When
359+
var result = ResultManager.GetAutoCompleteText(title, query, path, resultType);
360+
361+
// Then
362+
Assert.AreEqual(result, expectedResult);
363+
}
364+
365+
[TestCase("somefile", "c:\\somefolder\\somefile", ResultType.File, "q", false, false, "q somefile")]
366+
[TestCase("somefile", "c:\\somefolder\\somefile", ResultType.File, "i", true, false, "p c:\\somefolder\\somefile")]
367+
[TestCase("somefile", "c:\\somefolder\\somefile", ResultType.File, "irrelevant", true, true, "c:\\somefolder\\somefile")]
368+
public void GivenQueryWithFileTypeResult_WhenGetAutoComplete_ThenResultShouldBeExpectedString(
369+
string title,
370+
string path,
371+
ResultType resultType,
372+
string actionKeyword,
373+
bool pathSearchKeywordEnabled,
374+
bool searchActionKeywordEnabled,
375+
string expectedResult)
376+
{
377+
// Given
378+
var query = new Query() { ActionKeyword = actionKeyword };
379+
var settings = new Settings()
380+
{
381+
QuickAccessActionKeyword = "q",
382+
IndexSearchActionKeyword = "i",
383+
PathSearchActionKeyword = "p",
384+
PathSearchKeywordEnabled = pathSearchKeywordEnabled,
385+
SearchActionKeywordEnabled = searchActionKeywordEnabled,
386+
SearchActionKeyword = Query.GlobalPluginWildcardSign
387+
};
388+
ResultManager.Init(new PluginInitContext(), settings);
389+
390+
// When
391+
var result = ResultManager.GetAutoCompleteText(title, query, path, resultType);
392+
393+
// Then
394+
Assert.AreEqual(result, expectedResult);
395+
}
272396
}
273397
}

Flow.Launcher/Resources/CustomControlTemplate.xaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2999,8 +2999,6 @@
29992999
<Setter TargetName="KeyboardAcceleratorTextBlock" Property="Foreground" Value="{DynamicResource MenuFlyoutItemKeyboardAcceleratorTextForegroundPressed}" />
30003000
</Trigger>
30013001
<Trigger Property="IsEnabled" Value="False">
3002-
<!-- Hide Disabled Item -->
3003-
<Setter TargetName="LayoutRoot" Property="Visibility" Value="Collapsed" />
30043002
<Setter TargetName="LayoutRoot" Property="Background" Value="{DynamicResource MenuFlyoutItemBackgroundDisabled}" />
30053003
<Setter TargetName="LayoutRoot" Property="TextElement.Foreground" Value="{DynamicResource MenuFlyoutItemForegroundDisabled}" />
30063004
<Setter TargetName="ContentPresenter" Property="TextElement.Foreground" Value="{DynamicResource MenuFlyoutItemForegroundDisabled}" />

Flow.Launcher/ViewModel/MainViewModel.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -780,8 +780,16 @@ private Query ConstructQuery(string queryText, IEnumerable<CustomShortcutModel>
780780
{
781781
foreach (var shortcut in builtInShortcuts)
782782
{
783-
queryBuilder.Replace(shortcut.Key, shortcut.Expand());
784-
queryBuilderTmp.Replace(shortcut.Key, shortcut.Expand());
783+
try
784+
{
785+
var expansion = shortcut.Expand();
786+
queryBuilder.Replace(shortcut.Key, expansion);
787+
queryBuilderTmp.Replace(shortcut.Key, expansion);
788+
}
789+
catch (Exception e)
790+
{
791+
Log.Exception($"{nameof(MainViewModel)}.{nameof(ConstructQuery)}|Error when expanding shortcut {shortcut.Key}", e);
792+
}
785793
}
786794
});
787795

Flow.Launcher/ViewModel/SettingWindowViewModel.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,9 @@ public List<SearchWindowPosition> SearchWindowPositions
500500
"tt h:mm",
501501
"tt hh:mm",
502502
"h:mm tt",
503-
"hh:mm tt"
503+
"hh:mm tt",
504+
"hh:mm:ss tt",
505+
"HH:mm:ss"
504506
};
505507

506508
public List<string> DateFormatList { get; } = new()

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

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,22 @@ public static void Init(PluginInitContext context, Settings settings)
2121
Settings = settings;
2222
}
2323

24-
private static string GetPathWithActionKeyword(string path, ResultType type, string actionKeyword)
24+
public static string GetPathWithActionKeyword(string path, ResultType type, string actionKeyword)
2525
{
26-
// Query.ActionKeyword is string.Empty when Global Action Keyword ('*') is used
27-
var keyword = actionKeyword != string.Empty ? actionKeyword + " " : string.Empty;
26+
// actionKeyword will be empty string if using global, query.ActionKeyword is ""
2827

28+
var usePathSearchActionKeyword = Settings.PathSearchKeywordEnabled && !Settings.SearchActionKeywordEnabled;
29+
30+
var pathSearchActionKeyword = Settings.PathSearchActionKeyword == Query.GlobalPluginWildcardSign
31+
? string.Empty
32+
: $"{Settings.PathSearchActionKeyword} ";
33+
34+
var searchActionKeyword = Settings.SearchActionKeyword == Query.GlobalPluginWildcardSign
35+
? string.Empty
36+
: $"{Settings.SearchActionKeyword} ";
37+
38+
var keyword = usePathSearchActionKeyword ? pathSearchActionKeyword : searchActionKeyword;
39+
2940
var formatted_path = path;
3041

3142
if (type == ResultType.Folder)
@@ -35,6 +46,13 @@ private static string GetPathWithActionKeyword(string path, ResultType type, str
3546
return $"{keyword}{formatted_path}";
3647
}
3748

49+
public static string GetAutoCompleteText(string title, Query query, string path, ResultType resultType)
50+
{
51+
return !Settings.PathSearchKeywordEnabled && !Settings.SearchActionKeywordEnabled
52+
? $"{query.ActionKeyword} {title}" // Only Quick Access action keyword is used in this scenario
53+
: GetPathWithActionKeyword(path, resultType, query.ActionKeyword);
54+
}
55+
3856
public static Result CreateResult(Query query, SearchResult result)
3957
{
4058
return result.Type switch
@@ -54,7 +72,7 @@ internal static Result CreateFolderResult(string title, string subtitle, string
5472
Title = title,
5573
IcoPath = path,
5674
SubTitle = Path.GetDirectoryName(path),
57-
AutoCompleteText = GetPathWithActionKeyword(path, ResultType.Folder, query.ActionKeyword),
75+
AutoCompleteText = GetAutoCompleteText(title, query, path, ResultType.Folder),
5876
TitleHighlightData = StringMatcher.FuzzySearch(query.Search, title).MatchData,
5977
CopyText = path,
6078
Action = c =>
@@ -202,14 +220,16 @@ internal static Result CreateFileResult(string filePath, Query query, int score
202220
PreviewImagePath = filePath,
203221
} : Result.PreviewInfo.Default;
204222

223+
var title = Path.GetFileName(filePath);
224+
205225
var result = new Result
206226
{
207-
Title = Path.GetFileName(filePath),
227+
Title = title,
208228
SubTitle = Path.GetDirectoryName(filePath),
209229
IcoPath = filePath,
210230
Preview = preview,
211-
AutoCompleteText = GetPathWithActionKeyword(filePath, ResultType.File, query.ActionKeyword),
212-
TitleHighlightData = StringMatcher.FuzzySearch(query.Search, Path.GetFileName(filePath)).MatchData,
231+
AutoCompleteText = GetAutoCompleteText(title, query, filePath, ResultType.File),
232+
TitleHighlightData = StringMatcher.FuzzySearch(query.Search, title).MatchData,
213233
Score = score,
214234
CopyText = filePath,
215235
Action = c =>

Plugins/Flow.Launcher.Plugin.WindowsSettings/WindowsSettings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3419,7 +3419,7 @@
34193419
"Name": "CreateAndFormatHardDiskPartitions",
34203420
"Area": "Unknown",
34213421
"Type": "TaskLink",
3422-
"Command": "%windir%\\system32\\mmc.exe %windir%\\system32\\diskmgmt.msc",
3422+
"Command": "%windir%\\system32\\diskmgmt.msc",
34233423
"Keywords": [
34243424
[
34253425
"clean-up",

0 commit comments

Comments
 (0)