@@ -1331,53 +1331,63 @@ private Query ConstructQuery(string queryText, IEnumerable<CustomShortcutModel>
1331
1331
queryBuilder . Replace ( '@' + shortcut . Key , shortcut . Expand ( ) ) ;
1332
1332
}
1333
1333
1334
- var customExpanded = queryBuilder . ToString ( ) ;
1334
+ // Applying builtin shortcuts
1335
+ BuildQuery ( builtInShortcuts , queryBuilder , queryBuilderTmp ) ;
1335
1336
1336
- // We must use dispatcher because text here will be used in TextBox
1337
- Application . Current ? . Dispatcher . Invoke ( ( ) =>
1337
+ return QueryBuilder . Build ( queryBuilder . ToString ( ) . Trim ( ) , PluginManager . NonGlobalPlugins ) ;
1338
+ }
1339
+
1340
+ // We must use dispatcher because text here will be used in TextBox
1341
+ private void BuildQuery ( IEnumerable < BaseBuiltinShortcutModel > builtInShortcuts ,
1342
+ StringBuilder queryBuilder , StringBuilder queryBuilderTmp )
1343
+ {
1344
+ if ( ! Application . Current . Dispatcher . CheckAccess ( ) )
1338
1345
{
1339
- var queryChanged = false ;
1346
+ Application . Current . Dispatcher . Invoke ( ( ) => BuildQuery ( builtInShortcuts , queryBuilder , queryBuilderTmp ) ) ;
1347
+ return ;
1348
+ }
1340
1349
1341
- foreach ( var shortcut in builtInShortcuts )
1350
+ var customExpanded = queryBuilder . ToString ( ) ;
1351
+
1352
+ var queryChanged = false ;
1353
+
1354
+ foreach ( var shortcut in builtInShortcuts )
1355
+ {
1356
+ string expansion ;
1357
+ if ( shortcut is BuiltinShortcutModel syncShortcut )
1342
1358
{
1343
- string expansion ;
1344
- if ( shortcut is BuiltinShortcutModel syncShortcut )
1345
- {
1346
- expansion = syncShortcut . Expand ( ) ;
1347
- }
1348
- else if ( shortcut is AsyncBuiltinShortcutModel asyncShortcut )
1349
- {
1350
- expansion = App . JTF . Run ( ( ) => asyncShortcut . ExpandAsync ( ) ) ;
1351
- }
1352
- else
1353
- {
1354
- continue ;
1355
- }
1356
- try
1357
- {
1358
- if ( customExpanded . Contains ( shortcut . Key ) )
1359
- {
1360
- queryBuilder . Replace ( shortcut . Key , expansion ) ;
1361
- queryBuilderTmp . Replace ( shortcut . Key , expansion ) ;
1362
- queryChanged = true ;
1363
- }
1364
- }
1365
- catch ( Exception e )
1359
+ expansion = syncShortcut . Expand ( ) ;
1360
+ }
1361
+ else if ( shortcut is AsyncBuiltinShortcutModel asyncShortcut )
1362
+ {
1363
+ expansion = App . JTF . Run ( ( ) => asyncShortcut . ExpandAsync ( ) ) ;
1364
+ }
1365
+ else
1366
+ {
1367
+ continue ;
1368
+ }
1369
+ try
1370
+ {
1371
+ if ( customExpanded . Contains ( shortcut . Key ) )
1366
1372
{
1367
- App . API . LogException ( ClassName , $ "Error when expanding shortcut { shortcut . Key } ", e ) ;
1373
+ queryBuilder . Replace ( shortcut . Key , expansion ) ;
1374
+ queryBuilderTmp . Replace ( shortcut . Key , expansion ) ;
1375
+ queryChanged = true ;
1368
1376
}
1369
1377
}
1370
-
1371
- if ( queryChanged )
1378
+ catch ( Exception e )
1372
1379
{
1373
- // show expanded builtin shortcuts
1374
- // use private field to avoid infinite recursion
1375
- _queryText = queryBuilderTmp . ToString ( ) ;
1376
- OnPropertyChanged ( nameof ( QueryText ) ) ;
1380
+ App . API . LogException ( ClassName , $ "Error when expanding shortcut { shortcut . Key } ", e ) ;
1377
1381
}
1378
- } ) ;
1382
+ }
1379
1383
1380
- return QueryBuilder . Build ( queryBuilder . ToString ( ) . Trim ( ) , PluginManager . NonGlobalPlugins ) ;
1384
+ if ( queryChanged )
1385
+ {
1386
+ // show expanded builtin shortcuts
1387
+ // use private field to avoid infinite recursion
1388
+ _queryText = queryBuilderTmp . ToString ( ) ;
1389
+ OnPropertyChanged ( nameof ( QueryText ) ) ;
1390
+ }
1381
1391
}
1382
1392
1383
1393
private void RemoveOldQueryResults ( Query query )
0 commit comments