@@ -122,7 +122,7 @@ object QuickSearch {
122122 val results = performSearch(query)
123123
124124 if (results.isEmpty()) {
125- textColored( 0.7f , 0.7f , 0.7f , 1.0f , " No results found" )
125+ textDisabled( " No results found" )
126126 } else {
127127 text(" Results (${results.size} ):" )
128128 child(" SearchResults" , 400f , 300f , true ) {
@@ -138,12 +138,12 @@ object QuickSearch {
138138 }
139139
140140 sameLine()
141- textColored( 0.6f , 0.6f , 0.6f , 1.0f , " [${result.type.displayName} ]" )
141+ textDisabled( " [${result.type.displayName} ]" )
142142 }
143143 }
144144 }
145145 } else {
146- textColored( 0.7f , 0.7f , 0.7f , 1.0f , " Type to search modules, settings, and commands..." )
146+ textDisabled( " Type to search modules, settings, and commands..." )
147147 }
148148
149149 separator()
@@ -176,11 +176,12 @@ object QuickSearch {
176176 private fun searchModules (query : String , results : MutableList <SearchResult >) {
177177 // Direct name matches first
178178 ModuleRegistry .modules.forEach { module ->
179- if (module.name.lowercase().contains(query)) {
179+ val moduleNameLower = module.name.lowercase()
180+ if (moduleNameLower.contains(query) || moduleNameLower.startsWith(query)) {
180181 results.add(SearchResult (
181182 name = module.name,
182183 type = SearchResultType .MODULE ,
183- description = module.description,
184+ description = " ${ module.description} ( ${ if (module.isEnabled) " Enabled " else " Disabled " } ) " ,
184185 action = { module.toggle() }
185186 ))
186187 }
@@ -197,7 +198,7 @@ object QuickSearch {
197198 results.add(SearchResult (
198199 name = module.name,
199200 type = SearchResultType .MODULE ,
200- description = module.description,
201+ description = " ${ module.description} ( ${ if (module.isEnabled) " Enabled " else " Disabled " } ) " ,
201202 action = { module.toggle() }
202203 ))
203204 }
@@ -207,35 +208,70 @@ object QuickSearch {
207208
208209 private fun searchCommands (query : String , results : MutableList <SearchResult >) {
209210 CommandRegistry .commands.forEach { command ->
210- if (command.name.lowercase().contains(query) ||
211+ val commandNameLower = command.name.lowercase()
212+ if (commandNameLower.contains(query) ||
211213 command.aliases.any { it.lowercase().contains(query) }) {
212214 results.add(SearchResult (
213215 name = command.name,
214216 type = SearchResultType .COMMAND ,
215- description = command.description,
217+ description = " ${ command.description} (prefix: ${ CommandRegistry .prefix} ) " ,
216218 action = {
217- // For commands, we could open chat with the command prefix
218- // but that's complex, so for now just show info
219+ // For commands, show info about usage
220+ println ( " Command: ${ CommandRegistry .prefix}${command.name} - ${command.description} " )
219221 }
220222 ))
221223 }
222224 }
225+
226+ // Add fuzzy matching for commands too
227+ if (results.count { it.type == SearchResultType .COMMAND } < 5 ) {
228+ val commandNames = CommandRegistry .commands.map { it.name }.toSet()
229+ val similarNames = findSimilarStrings(query, commandNames, searchThreshold)
230+
231+ similarNames.forEach { name ->
232+ val command = CommandRegistry .commands.find { it.name == name }
233+ if (command != null && results.none { it.name == name && it.type == SearchResultType .COMMAND }) {
234+ results.add(SearchResult (
235+ name = command.name,
236+ type = SearchResultType .COMMAND ,
237+ description = " ${command.description} (prefix: ${CommandRegistry .prefix} )" ,
238+ action = {
239+ println (" Command: ${CommandRegistry .prefix}${command.name} - ${command.description} " )
240+ }
241+ ))
242+ }
243+ }
244+ }
223245 }
224246
225247 private fun searchSettings (query : String , results : MutableList <SearchResult >) {
248+ // Limit setting search to avoid too many results
249+ var settingCount = 0
250+ val maxSettings = 15
251+
226252 Configuration .configurations.forEach { config ->
253+ if (settingCount >= maxSettings) return @forEach
254+
227255 config.configurables.forEach { configurable ->
256+ if (settingCount >= maxSettings) return @forEach
257+
228258 configurable.settings.forEach { setting ->
229- if (setting.name.lowercase().contains(query)) {
259+ if (settingCount >= maxSettings) return @forEach
260+
261+ val settingNameLower = setting.name.lowercase()
262+ val configurableName = configurable.name.lowercase()
263+
264+ if (settingNameLower.contains(query) || configurableName.contains(query)) {
230265 results.add(SearchResult (
231266 name = " ${configurable.name} .${setting.name} " ,
232267 type = SearchResultType .SETTING ,
233- description = setting.description,
268+ description = setting.description.ifEmpty { " Setting in ${configurable.name} " } ,
234269 action = {
235- // For settings, we could navigate to the setting
236- // but that's complex for now
270+ // For settings, show current value
271+ println ( " Setting: ${configurable.name} . ${setting.name} = ${setting.value} " )
237272 }
238273 ))
274+ settingCount++
239275 }
240276 }
241277 }
0 commit comments