File tree 2 files changed +14
-16
lines changed 2 files changed +14
-16
lines changed Original file line number Diff line number Diff line change @@ -11,15 +11,14 @@ function triggerAutocompletePlus() {
11
11
}
12
12
exports . triggerAutocompletePlus = triggerAutocompletePlus ;
13
13
function getModuleAutocompleteType ( scopes ) {
14
- var has = scopes . reduce ( function ( scopes , name ) {
15
- scopes [ name ] = true ;
16
- return scopes ;
17
- } , { } ) ;
18
- var isString = has [ 'string.quoted.double.ts' ] || has [ 'string.quoted.single.ts' ] || false ;
14
+ function has ( match ) {
15
+ return scopes . some ( function ( scope ) { return scope . indexOf ( match ) !== - 1 ; } ) ;
16
+ }
17
+ var isString = has ( 'string.quoted' ) ;
19
18
return {
20
- isReference : has [ 'reference.path.string.quoted' ] || has [ 'amd.path.string.quoted' ] || false ,
21
- isRequire : has [ 'meta.import-equals.external.ts' ] && isString || false ,
22
- isImport : has [ 'meta.import.ts' ] && isString || false
19
+ isReference : has ( 'reference.path.string.quoted' ) || has ( 'amd.path.string.quoted' ) ,
20
+ isRequire : has ( 'meta.import-equals.external' ) && isString ,
21
+ isImport : has ( 'meta.import' ) && isString
23
22
} ;
24
23
}
25
24
exports . provider = {
Original file line number Diff line number Diff line change @@ -73,17 +73,16 @@ function getModuleAutocompleteType(scopes: string[]): {
73
73
isRequire : boolean , // this only matches: import hello = require("^cursor") and not require("^")
74
74
isImport : boolean // ES6 import: import hello from "^cursor"
75
75
} {
76
- let has = scopes . reduce ( ( scopes , name ) => {
77
- scopes [ name ] = true
78
- return scopes
79
- } , { } as { [ key : string ] : boolean } )
76
+ function has ( match : string ) : boolean {
77
+ return scopes . some ( scope => scope . indexOf ( match ) !== - 1 )
78
+ }
80
79
81
- let isString = has [ 'string.quoted.double.ts' ] || has [ 'string.quoted.single.ts' ] || false
80
+ let isString = has ( 'string.quoted' )
82
81
83
82
return {
84
- isReference : has [ 'reference.path.string.quoted' ] || has [ 'amd.path.string.quoted' ] || false ,
85
- isRequire : has [ 'meta.import-equals.external.ts' ] && isString || false ,
86
- isImport : has [ 'meta.import.ts' ] && isString || false
83
+ isReference : has ( 'reference.path.string.quoted' ) || has ( 'amd.path.string.quoted' ) ,
84
+ isRequire : has ( 'meta.import-equals.external' ) && isString ,
85
+ isImport : has ( 'meta.import' ) && isString
87
86
}
88
87
}
89
88
You can’t perform that action at this time.
0 commit comments