@@ -10,10 +10,12 @@ namespace Flow.Launcher.Plugin.Explorer.Search
10
10
public static class ResultManager
11
11
{
12
12
private static PluginInitContext Context ;
13
+ private static Settings Settings { get ; set ; }
13
14
14
- public static void Init ( PluginInitContext context )
15
+ public static void Init ( PluginInitContext context , Settings settings )
15
16
{
16
17
Context = context ;
18
+ Settings = settings ;
17
19
}
18
20
19
21
internal static Result CreateFolderResult ( string title , string subtitle , string path , Query query , int score = 0 , bool showIndexState = false , bool windowsIndexed = false )
@@ -26,7 +28,7 @@ internal static Result CreateFolderResult(string title, string subtitle, string
26
28
TitleHighlightData = StringMatcher . FuzzySearch ( query . Search , title ) . MatchData ,
27
29
Action = c =>
28
30
{
29
- if ( c . SpecialKeyState . CtrlPressed )
31
+ if ( c . SpecialKeyState . CtrlPressed || ( ! Settings . PathSearchKeywordEnabled && ! Settings . SearchActionKeywordEnabled ) )
30
32
{
31
33
try
32
34
{
@@ -39,25 +41,36 @@ internal static Result CreateFolderResult(string title, string subtitle, string
39
41
return false ;
40
42
}
41
43
}
44
+ // one of it is enabled
45
+ var keyword = Settings . SearchActionKeywordEnabled ? Settings . SearchActionKeyword : Settings . PathSearchActionKeyword ;
46
+
47
+ keyword = keyword == Query . GlobalPluginWildcardSign ? string . Empty : keyword + " " ;
42
48
43
49
string changeTo = path . EndsWith ( Constants . DirectorySeperator ) ? path : path + Constants . DirectorySeperator ;
44
- Context . API . ChangeQuery ( string . IsNullOrEmpty ( query . ActionKeyword ) ?
45
- changeTo :
46
- query . ActionKeyword + " " + changeTo ) ;
50
+ Context . API . ChangeQuery ( $ "{ keyword } { changeTo } ") ;
47
51
return false ;
48
52
} ,
49
53
Score = score ,
50
54
TitleToolTip = Constants . ToolTipOpenDirectory ,
51
55
SubTitleToolTip = Constants . ToolTipOpenDirectory ,
52
- ContextData = new SearchResult { Type = ResultType . Folder , FullPath = path , ShowIndexState = showIndexState , WindowsIndexed = windowsIndexed }
56
+ ContextData = new SearchResult
57
+ {
58
+ Type = ResultType . Folder ,
59
+ FullPath = path ,
60
+ ShowIndexState = showIndexState ,
61
+ WindowsIndexed = windowsIndexed
62
+ }
53
63
} ;
54
64
}
55
65
56
66
internal static Result CreateOpenCurrentFolderResult ( string path , bool windowsIndexed = false )
57
67
{
58
68
var retrievedDirectoryPath = FilesFolders . ReturnPreviousDirectoryIfIncompleteString ( path ) ;
59
69
60
- var folderName = retrievedDirectoryPath . TrimEnd ( Constants . DirectorySeperator ) . Split ( new [ ] { Path . DirectorySeparatorChar } , StringSplitOptions . None ) . Last ( ) ;
70
+ var folderName = retrievedDirectoryPath . TrimEnd ( Constants . DirectorySeperator ) . Split ( new [ ]
71
+ {
72
+ Path . DirectorySeparatorChar
73
+ } , StringSplitOptions . None ) . Last ( ) ;
61
74
62
75
if ( retrievedDirectoryPath . EndsWith ( ":\\ " ) )
63
76
{
@@ -81,7 +94,7 @@ internal static Result CreateOpenCurrentFolderResult(string path, bool windowsIn
81
94
{
82
95
Title = title ,
83
96
SubTitle = $ "Use > to search within { subtitleFolderName } , " +
84
- $ "* to search for file extensions or >* to combine both searches.",
97
+ $ "* to search for file extensions or >* to combine both searches.",
85
98
IcoPath = retrievedDirectoryPath ,
86
99
Score = 500 ,
87
100
Action = c =>
@@ -91,7 +104,13 @@ internal static Result CreateOpenCurrentFolderResult(string path, bool windowsIn
91
104
} ,
92
105
TitleToolTip = retrievedDirectoryPath ,
93
106
SubTitleToolTip = retrievedDirectoryPath ,
94
- ContextData = new SearchResult { Type = ResultType . Folder , FullPath = retrievedDirectoryPath , ShowIndexState = true , WindowsIndexed = windowsIndexed }
107
+ ContextData = new SearchResult
108
+ {
109
+ Type = ResultType . Folder ,
110
+ FullPath = retrievedDirectoryPath ,
111
+ ShowIndexState = true ,
112
+ WindowsIndexed = windowsIndexed
113
+ }
95
114
} ;
96
115
}
97
116
@@ -126,7 +145,13 @@ internal static Result CreateFileResult(string filePath, Query query, int score
126
145
} ,
127
146
TitleToolTip = Constants . ToolTipOpenContainingFolder ,
128
147
SubTitleToolTip = Constants . ToolTipOpenContainingFolder ,
129
- ContextData = new SearchResult { Type = ResultType . File , FullPath = filePath , ShowIndexState = showIndexState , WindowsIndexed = windowsIndexed }
148
+ ContextData = new SearchResult
149
+ {
150
+ Type = ResultType . File ,
151
+ FullPath = filePath ,
152
+ ShowIndexState = showIndexState ,
153
+ WindowsIndexed = windowsIndexed
154
+ }
130
155
} ;
131
156
return result ;
132
157
}
@@ -148,4 +173,4 @@ public enum ResultType
148
173
Folder ,
149
174
File
150
175
}
151
- }
176
+ }
0 commit comments