File tree Expand file tree Collapse file tree 3 files changed +14
-6
lines changed Expand file tree Collapse file tree 3 files changed +14
-6
lines changed Original file line number Diff line number Diff line change 18
18
"dependencies" : {
19
19
"esnext-coverage" : " ^0.0.2" ,
20
20
"esnext-coverage-analytics" : " ^0.0.3" ,
21
+ "fuzzaldrin" : " ^2.1.0" ,
21
22
"redux" : " ^3.6.0" ,
22
23
"url-parse" : " ^1.1.3" ,
23
24
"virtual-dom" : " ^2.1.1"
Original file line number Diff line number Diff line change 1
1
import h from 'virtual-dom/h' ;
2
2
import store from '../../store' ;
3
+ import search from '../../services/search' ;
3
4
4
5
function suggestionsSelector ( state ) {
5
- const current = state . location . path [ 0 ] ;
6
- return Object
6
+ const query = state . search ;
7
+ if ( ! query ) { return [ ] ; }
8
+ const currentLocation = state . location . path [ 0 ] ;
9
+ const candidates = Object
7
10
. keys ( state . files . contents )
8
- . filter ( fileName => {
9
- return state . search && current !== fileName && fileName . includes ( state . search ) ;
10
- } ) ;
11
+ . filter ( fileName => fileName !== currentLocation ) ;
12
+ return search ( candidates , query , { maxResults : 7 } ) ;
11
13
}
12
14
13
15
function clearSearch ( ) {
@@ -50,7 +52,7 @@ function searchSuggestionList(suggestions) {
50
52
} , suggestions . map ( searchSuggestion ) ) ;
51
53
}
52
54
53
- export default function search ( state ) {
55
+ export default function searchComponent ( state ) {
54
56
return h ( 'div' , {
55
57
className : 'search'
56
58
} , [
Original file line number Diff line number Diff line change
1
+ import { filter } from 'fuzzaldrin' ;
2
+
3
+ export default function search ( candidates , query , options ) {
4
+ return filter ( candidates , query , options ) ;
5
+ }
You can’t perform that action at this time.
0 commit comments