@@ -223,7 +223,7 @@ protected function fetchColumnSuggestions($searchTerm)
223
223
224
224
$ parsedArrayVars = [];
225
225
$ exactSearchTerm = trim ($ searchTerm , ' * ' );
226
- $ exactVarMatches = [];
226
+ $ exactVarSearches = [];
227
227
$ titleAdded = false ;
228
228
229
229
// Suggest exact custom variable matches first
@@ -237,6 +237,7 @@ protected function fetchColumnSuggestions($searchTerm)
237
237
)) as $ customVar
238
238
) {
239
239
$ search = $ name = $ customVar ->flatname ;
240
+ $ exactVarSearches [] = $ search ;
240
241
if (preg_match ('/\w+(?:\[(\d*)])+$/ ' , $ search , $ matches )) {
241
242
$ name = substr ($ search , 0 , -(strlen ($ matches [1 ]) + 2 ));
242
243
if (isset ($ parsedArrayVars [$ name ])) {
@@ -249,7 +250,6 @@ protected function fetchColumnSuggestions($searchTerm)
249
250
250
251
foreach ($ this ->customVarSources as $ relation => $ label ) {
251
252
if (isset ($ customVar ->$ relation )) {
252
- $ varRelation = $ relation . '.vars. ' . $ search ;
253
253
if ($ titleAdded === false ) {
254
254
$ this ->addHtml (HtmlElement::create (
255
255
'li ' ,
@@ -260,9 +260,7 @@ protected function fetchColumnSuggestions($searchTerm)
260
260
$ titleAdded = true ;
261
261
}
262
262
263
- $ exactVarMatches [] = $ varRelation ;
264
-
265
- yield $ varRelation => sprintf ($ label , $ name );
263
+ yield $ relation . '.vars. ' . $ search => sprintf ($ label , $ name );
266
264
}
267
265
}
268
266
}
@@ -290,7 +288,12 @@ protected function fetchColumnSuggestions($searchTerm)
290
288
// Finally, the other custom variable suggestions
291
289
$ titleAdded = false ;
292
290
foreach (
293
- $ this ->getDb ()->select ($ this ->queryCustomvarConfig (Filter::like ('flatname ' , $ searchTerm ))) as $ customVar
291
+ $ this ->getDb ()->select ($ this ->queryCustomvarConfig (
292
+ Filter::all (
293
+ Filter::like ('flatname ' , $ searchTerm ),
294
+ Filter::unequal ('flatname ' , $ exactVarSearches )
295
+ )
296
+ )) as $ customVar
294
297
) {
295
298
$ search = $ name = $ customVar ->flatname ;
296
299
if (preg_match ('/\w+(?:\[(\d*)])+$/ ' , $ search , $ matches )) {
@@ -305,25 +308,18 @@ protected function fetchColumnSuggestions($searchTerm)
305
308
306
309
foreach ($ this ->customVarSources as $ relation => $ label ) {
307
310
if (isset ($ customVar ->$ relation )) {
308
- $ varRelation = $ relation . '.vars. ' . $ search ;
309
- $ varLabel = sprintf ($ label , $ name );
310
311
// Suggest exact custom variable matches first
311
- if (
312
- ! in_array ($ varRelation , $ exactVarMatches )
313
- && $ this ->matchSuggestion ($ varRelation , $ varLabel , $ searchTerm )
314
- ) {
315
- if ($ titleAdded === false ) {
316
- $ this ->addHtml (HtmlElement::create (
317
- 'li ' ,
318
- ['class ' => static ::SUGGESTION_TITLE_CLASS ],
319
- t ('Custom Variables ' )
320
- ));
321
-
322
- $ titleAdded = true ;
323
- }
324
-
325
- yield $ varRelation => $ varLabel ;
312
+ if ($ titleAdded === false ) {
313
+ $ this ->addHtml (HtmlElement::create (
314
+ 'li ' ,
315
+ ['class ' => static ::SUGGESTION_TITLE_CLASS ],
316
+ t ('Custom Variables ' )
317
+ ));
318
+
319
+ $ titleAdded = true ;
326
320
}
321
+
322
+ yield $ relation . '.vars. ' . $ search => sprintf ($ label , $ name );
327
323
}
328
324
}
329
325
}
0 commit comments