@@ -10,10 +10,12 @@ namespace Flow.Launcher.Plugin.Explorer.Search
1010 public static class ResultManager
1111 {
1212 private static PluginInitContext Context ;
13+ private static Settings Settings { get ; set ; }
1314
14- public static void Init ( PluginInitContext context )
15+ public static void Init ( PluginInitContext context , Settings settings )
1516 {
1617 Context = context ;
18+ Settings = settings ;
1719 }
1820
1921 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
2628 TitleHighlightData = StringMatcher . FuzzySearch ( query . Search , title ) . MatchData ,
2729 Action = c =>
2830 {
29- if ( c . SpecialKeyState . CtrlPressed )
31+ if ( c . SpecialKeyState . CtrlPressed || ( ! Settings . PathSearchKeywordEnabled && ! Settings . SearchActionKeywordEnabled ) )
3032 {
3133 try
3234 {
@@ -39,25 +41,36 @@ internal static Result CreateFolderResult(string title, string subtitle, string
3941 return false ;
4042 }
4143 }
44+ // one of it is enabled
45+ var keyword = Settings . SearchActionKeywordEnabled ? Settings . SearchActionKeyword : Settings . PathSearchActionKeyword ;
46+
47+ keyword = keyword == Query . GlobalPluginWildcardSign ? string . Empty : keyword + " " ;
4248
4349 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 } ") ;
4751 return false ;
4852 } ,
4953 Score = score ,
5054 TitleToolTip = Constants . ToolTipOpenDirectory ,
5155 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+ }
5363 } ;
5464 }
5565
5666 internal static Result CreateOpenCurrentFolderResult ( string path , bool windowsIndexed = false )
5767 {
5868 var retrievedDirectoryPath = FilesFolders . ReturnPreviousDirectoryIfIncompleteString ( path ) ;
5969
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 ( ) ;
6174
6275 if ( retrievedDirectoryPath . EndsWith ( ":\\ " ) )
6376 {
@@ -81,7 +94,7 @@ internal static Result CreateOpenCurrentFolderResult(string path, bool windowsIn
8194 {
8295 Title = title ,
8396 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.",
8598 IcoPath = retrievedDirectoryPath ,
8699 Score = 500 ,
87100 Action = c =>
@@ -91,7 +104,13 @@ internal static Result CreateOpenCurrentFolderResult(string path, bool windowsIn
91104 } ,
92105 TitleToolTip = retrievedDirectoryPath ,
93106 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+ }
95114 } ;
96115 }
97116
@@ -126,7 +145,13 @@ internal static Result CreateFileResult(string filePath, Query query, int score
126145 } ,
127146 TitleToolTip = Constants . ToolTipOpenContainingFolder ,
128147 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+ }
130155 } ;
131156 return result ;
132157 }
@@ -148,4 +173,4 @@ public enum ResultType
148173 Folder ,
149174 File
150175 }
151- }
176+ }
0 commit comments