Skip to content
This repository was archived by the owner on Mar 18, 2024. It is now read-only.

Commit f98754f

Browse files
author
Tomás Senart
authored
search: Set explicit count:500 parameter in referencesQuery (#737)
1 parent 23039e5 commit f98754f

3 files changed

Lines changed: 37 additions & 3 deletions

File tree

template/src/search/providers.test.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ describe('search providers', () => {
155155
assert.strictEqual(searchStub.callCount, 1)
156156
assertQuery(searchStub.firstCall.args[0], [
157157
'^foobar$',
158+
'count:500',
158159
'case:yes',
159160
'patternType:regexp',
160161
'repo:^sourcegraph.test/repo$@rev',
@@ -178,6 +179,7 @@ describe('search providers', () => {
178179
assert.strictEqual(searchStub.callCount, 1)
179180
assertQuery(searchStub.firstCall.args[0], [
180181
'^foobar$',
182+
'count:500',
181183
'case:yes',
182184
'patternType:regexp',
183185
'repo:^sourcegraph.test/repo\\ with\\ spaces$@rev',
@@ -202,13 +204,15 @@ describe('search providers', () => {
202204
assert.strictEqual(searchStub.callCount, 2)
203205
assertQuery(searchStub.firstCall.args[0], [
204206
'^foobar$',
207+
'count:500',
205208
'case:yes',
206209
'patternType:regexp',
207210
'repo:^sourcegraph.test/repo$@rev',
208211
'type:symbol',
209212
])
210213
assertQuery(searchStub.secondCall.args[0], [
211214
'^foobar$',
215+
'count:500',
212216
'case:yes',
213217
'patternType:regexp',
214218
'-repo:^sourcegraph.test/repo$',
@@ -252,13 +256,15 @@ describe('search providers', () => {
252256
assert.strictEqual(searchStub.callCount, 2)
253257
assertQuery(searchStub.firstCall.args[0], [
254258
'^foobar$',
259+
'count:500',
255260
'case:yes',
256261
'patternType:regexp',
257262
'repo:^sourcegraph.test/repo$@rev',
258263
'type:symbol',
259264
])
260265
assertQuery(searchStub.secondCall.args[0], [
261266
'^foobar$',
267+
'count:500',
262268
'case:yes',
263269
'patternType:regexp',
264270
'repo:^sourcegraph.test/repo$',
@@ -289,20 +295,23 @@ describe('search providers', () => {
289295
assert.strictEqual(searchStub.callCount, 3)
290296
assertQuery(searchStub.firstCall.args[0], [
291297
'^foobar$',
298+
'count:500',
292299
'case:yes',
293300
'patternType:regexp',
294301
'repo:^sourcegraph.test/repo$@rev',
295302
'type:symbol',
296303
])
297304
assertQuery(searchStub.secondCall.args[0], [
298305
'^foobar$',
306+
'count:500',
299307
'case:yes',
300308
'patternType:regexp',
301309
'-repo:^sourcegraph.test/repo$',
302310
'type:symbol',
303311
])
304312
assertQuery(searchStub.thirdCall.args[0], [
305313
'^foobar$',
314+
'count:500',
306315
'case:yes',
307316
'patternType:regexp',
308317
'-repo:^sourcegraph.test/repo$',
@@ -328,6 +337,7 @@ describe('search providers', () => {
328337
assert.strictEqual(searchStub.callCount, 2)
329338
assertQuery(searchStub.firstCall.args[0], [
330339
'^foobar$',
340+
'count:500',
331341
'case:yes',
332342
'fork:yes',
333343
'patternType:regexp',
@@ -336,6 +346,7 @@ describe('search providers', () => {
336346
])
337347
assertQuery(searchStub.secondCall.args[0], [
338348
'^foobar$',
349+
'count:500',
339350
'case:yes',
340351
'patternType:regexp',
341352
'-repo:^sourcegraph.test/repo$',
@@ -372,13 +383,15 @@ describe('search providers', () => {
372383
assert.strictEqual(searchStub.callCount, 2)
373384
assertQuery(searchStub.firstCall.args[0], [
374385
'\\bfoobar\\b',
386+
'count:500',
375387
'case:yes',
376388
'patternType:regexp',
377389
'repo:^sourcegraph.test/repo$@rev',
378390
'type:file',
379391
])
380392
assertQuery(searchStub.secondCall.args[0], [
381393
'\\bfoobar\\b',
394+
'count:500',
382395
'case:yes',
383396
'patternType:regexp',
384397
'-repo:^sourcegraph.test/repo$',
@@ -413,13 +426,15 @@ describe('search providers', () => {
413426
assert.strictEqual(searchStub.callCount, 2)
414427
assertQuery(searchStub.firstCall.args[0], [
415428
'\\bfoobar\\b',
429+
'count:500',
416430
'case:yes',
417431
'patternType:regexp',
418432
'repo:^sourcegraph.test/repo\\ with\\ spaces$@rev',
419433
'type:file',
420434
])
421435
assertQuery(searchStub.secondCall.args[0], [
422436
'\\bfoobar\\b',
437+
'count:500',
423438
'case:yes',
424439
'patternType:regexp',
425440
'-repo:^sourcegraph.test/repo\\ with\\ spaces$',
@@ -459,20 +474,23 @@ describe('search providers', () => {
459474
assert.strictEqual(searchStub.callCount, 4)
460475
assertQuery(searchStub.getCall(0).args[0], [
461476
'\\bfoobar\\b',
477+
'count:500',
462478
'case:yes',
463479
'patternType:regexp',
464480
'repo:^sourcegraph.test/repo$@rev',
465481
'type:file',
466482
])
467483
assertQuery(searchStub.getCall(1).args[0], [
468484
'\\bfoobar\\b',
485+
'count:500',
469486
'case:yes',
470487
'patternType:regexp',
471488
'-repo:^sourcegraph.test/repo$',
472489
'type:file',
473490
])
474491
assertQuery(searchStub.getCall(2).args[0], [
475492
'\\bfoobar\\b',
493+
'count:500',
476494
'case:yes',
477495
'patternType:regexp',
478496
'repo:^sourcegraph.test/repo$',
@@ -481,6 +499,7 @@ describe('search providers', () => {
481499
])
482500
assertQuery(searchStub.getCall(3).args[0], [
483501
'\\bfoobar\\b',
502+
'count:500',
484503
'case:yes',
485504
'patternType:regexp',
486505
'-repo:^sourcegraph.test/repo$',
@@ -521,6 +540,7 @@ describe('search providers', () => {
521540
assert.strictEqual(searchStub.callCount, 4)
522541
assertQuery(searchStub.getCall(0).args[0], [
523542
'\\bfoobar\\b',
543+
'count:500',
524544
'case:yes',
525545
'fork:yes',
526546
'patternType:regexp',
@@ -529,13 +549,15 @@ describe('search providers', () => {
529549
])
530550
assertQuery(searchStub.getCall(1).args[0], [
531551
'\\bfoobar\\b',
552+
'count:500',
532553
'case:yes',
533554
'patternType:regexp',
534555
'-repo:^sourcegraph.test/repo$',
535556
'type:file',
536557
])
537558
assertQuery(searchStub.getCall(2).args[0], [
538559
'\\bfoobar\\b',
560+
'count:500',
539561
'case:yes',
540562
'fork:yes',
541563
'index:only',
@@ -545,6 +567,7 @@ describe('search providers', () => {
545567
])
546568
assertQuery(searchStub.getCall(3).args[0], [
547569
'\\bfoobar\\b',
570+
'count:500',
548571
'case:yes',
549572
'patternType:regexp',
550573
'-repo:^sourcegraph.test/repo$',
@@ -587,6 +610,7 @@ describe('search providers', () => {
587610
assert.strictEqual(searchStub.callCount, 1)
588611
assertQuery(searchStub.firstCall.args[0], [
589612
'^foobar$',
613+
'count:500',
590614
'case:yes',
591615
'patternType:regexp',
592616
'repo:^sourcegraph.test/repo$@rev',
@@ -620,13 +644,15 @@ describe('search providers', () => {
620644
assert.strictEqual(searchStub.callCount, 2)
621645
assertQuery(searchStub.firstCall.args[0], [
622646
'^foobar$',
647+
'count:500',
623648
'case:yes',
624649
'patternType:regexp',
625650
'repo:^sourcegraph.test/repo$@rev',
626651
'type:symbol',
627652
])
628653
assertQuery(searchStub.secondCall.args[0], [
629654
'^foobar$',
655+
'count:500',
630656
'case:yes',
631657
'patternType:regexp',
632658
'repo:^sourcegraph.test/repo$',

template/src/search/queries.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ describe('search requests', () => {
2323
'^token$',
2424
'type:symbol',
2525
'patternType:regexp',
26+
'count:500',
2627
'case:yes',
2728
'file:\\.(cpp)$',
2829
],
@@ -57,6 +58,7 @@ describe('search requests', () => {
5758
'\\btoken\\b',
5859
'type:file',
5960
'patternType:regexp',
61+
'count:500',
6062
'case:yes',
6163
'file:\\.(cpp)$',
6264
],

template/src/search/queries.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,14 @@ export function definitionQuery({
2222
/** File extensions used by the current extension. */
2323
fileExts: string[]
2424
}): string[] {
25-
return [`^${searchToken}$`, 'type:symbol', 'patternType:regexp', 'case:yes', fileExtensionTerm(doc, fileExts)]
26-
// return [`${searchToken}`, 'type:symbol', 'patternType:regexp', 'case:yes', fileExtensionTerm(doc, fileExts)]
25+
return [
26+
`^${searchToken}$`,
27+
'type:symbol',
28+
'patternType:regexp',
29+
'count:500',
30+
'case:yes',
31+
fileExtensionTerm(doc, fileExts),
32+
]
2733
}
2834

2935
/**
@@ -51,7 +57,7 @@ export function referencesQuery({
5157
if (/\w$/.test(searchToken)) {
5258
pattern += '\\b'
5359
}
54-
return [pattern, 'type:file', 'patternType:regexp', 'case:yes', fileExtensionTerm(doc, fileExts)]
60+
return [pattern, 'type:file', 'patternType:regexp', 'count:500', 'case:yes', fileExtensionTerm(doc, fileExts)]
5561
}
5662

5763
const excludelist = new Set(['thrift', 'proto', 'graphql'])

0 commit comments

Comments
 (0)