@@ -13,19 +13,26 @@ public static class ResultManager
1313 {
1414 private static PluginInitContext Context ;
1515 private static Settings Settings { get ; set ; }
16- public static object Keyword { get ; private set ; }
1716
1817 public static void Init ( PluginInitContext context , Settings settings )
1918 {
2019 Context = context ;
2120 Settings = settings ;
22- Keyword = Settings . SearchActionKeywordEnabled ? Settings . SearchActionKeyword : Settings . PathSearchActionKeyword ;
23- Keyword = Keyword . ToString ( ) == Query . GlobalPluginWildcardSign ? string . Empty : Keyword + " " ;
2421 }
2522
26- public static string ChangeToPath ( string path )
23+ private static string GetPathWithActionKeyword ( string path , ResultType type )
2724 {
28- return path . EndsWith ( Constants . DirectorySeperator ) ? path : path + Constants . DirectorySeperator ;
25+ // one of it is enabled
26+ var keyword = Settings . SearchActionKeywordEnabled ? Settings . SearchActionKeyword : Settings . PathSearchActionKeyword ;
27+
28+ keyword = keyword == Query . GlobalPluginWildcardSign ? string . Empty : keyword + " " ;
29+
30+ var formatted_path = path ;
31+
32+ if ( type == ResultType . Folder )
33+ formatted_path = path . EndsWith ( Constants . DirectorySeperator ) ? path : path + Constants . DirectorySeperator ;
34+
35+ return $ "{ keyword } { formatted_path } ";
2936 }
3037
3138 internal static Result CreateFolderResult ( string title , string subtitle , string path , Query query , int score = 0 , bool showIndexState = false , bool windowsIndexed = false )
@@ -35,7 +42,7 @@ internal static Result CreateFolderResult(string title, string subtitle, string
3542 Title = title ,
3643 IcoPath = path ,
3744 SubTitle = subtitle ,
38- AutoCompleteText = $ " { Keyword } { ChangeToPath ( path ) } " ,
45+ AutoCompleteText = GetPathWithActionKeyword ( path , ResultType . Folder ) ,
3946 TitleHighlightData = StringMatcher . FuzzySearch ( query . Search , title ) . MatchData ,
4047 Action = c =>
4148 {
@@ -52,7 +59,9 @@ internal static Result CreateFolderResult(string title, string subtitle, string
5259 return false ;
5360 }
5461 }
55- Context . API . ChangeQuery ( $ "{ Keyword } { ChangeToPath ( path ) } ") ;
62+
63+ Context . API . ChangeQuery ( GetPathWithActionKeyword ( path , ResultType . Folder ) ) ;
64+
5665 return false ;
5766 } ,
5867 Score = score ,
@@ -100,6 +109,7 @@ internal static Result CreateOpenCurrentFolderResult(string path, bool windowsIn
100109 Title = title ,
101110 SubTitle = $ "Use > to search within { subtitleFolderName } , " +
102111 $ "* to search for file extensions or >* to combine both searches.",
112+ AutoCompleteText = GetPathWithActionKeyword ( retrievedDirectoryPath , ResultType . Folder ) ,
103113 IcoPath = retrievedDirectoryPath ,
104114 Score = 500 ,
105115 Action = c =>
@@ -126,7 +136,7 @@ internal static Result CreateFileResult(string filePath, Query query, int score
126136 Title = Path . GetFileName ( filePath ) ,
127137 SubTitle = filePath ,
128138 IcoPath = filePath ,
129- AutoCompleteText = filePath ,
139+ AutoCompleteText = GetPathWithActionKeyword ( filePath , ResultType . File ) ,
130140 TitleHighlightData = StringMatcher . FuzzySearch ( query . Search , Path . GetFileName ( filePath ) ) . MatchData ,
131141 Score = score ,
132142 Action = c =>
0 commit comments