@@ -6,24 +6,25 @@ import { sortBy } from 'rambda'
6
6
export default ( entries : ts . CompletionEntry [ ] , languageService : ts . LanguageService , c : GetConfig ) => {
7
7
const ignoreAutoImportsSetting = getIgnoreAutoImportSetting ( c )
8
8
9
- let newEntries = entries . filter ( ( { sourceDisplay, name } ) => {
10
- if ( ! sourceDisplay ) return true
9
+ const ignoreKinds = [ ts . ScriptElementKind . warning , ts . ScriptElementKind . string ]
10
+ entries = entries . filter ( ( { sourceDisplay, name, kind } ) => {
11
+ if ( ! sourceDisplay || ignoreKinds . includes ( kind ) ) return true
11
12
const targetModule = ts . displayPartsToString ( sourceDisplay )
12
13
const toIgnore = isAutoImportEntryShouldBeIgnored ( ignoreAutoImportsSetting , targetModule , name )
13
14
return ! toIgnore
14
15
} )
15
16
// todo I'm not sure of incomplete completion (wasnt tested)
16
17
// todo don't forget to impl glob there
17
18
const handledSymbolNames = new Set < string > ( )
18
- for ( const [ i , entry ] of newEntries . entries ( ) ) {
19
+ for ( const [ i , entry ] of entries . entries ( ) ) {
19
20
const { name } = entry
20
21
if ( ! entry . sourceDisplay || handledSymbolNames . has ( name ) ) continue
21
22
if ( ! shouldChangeSortingOfAutoImport ( name , c ) ) continue
22
23
handledSymbolNames . add ( name )
23
24
const sortFn = changeSortingOfAutoImport ( c , name )
24
25
// TODO probably should be rewrited
25
26
const entriesToSort : ts . CompletionEntry [ ] = [ ]
26
- newEntries = newEntries . filter ( ( entry , k ) => {
27
+ entries = entries . filter ( ( entry , k ) => {
27
28
if ( k < i ) return true
28
29
if ( entry . sourceDisplay && entry . name === name ) {
29
30
entriesToSort . push ( entry )
@@ -33,7 +34,7 @@ export default (entries: ts.CompletionEntry[], languageService: ts.LanguageServi
33
34
} )
34
35
// todo rewrite outer that for loop to index based and increment here on insert length + handledSymbolNames can be removed in that case
35
36
// final one seems to be slow, e.g. it might be slowing down completions
36
- newEntries . splice ( i , 0 , ...sortBy ( ( { sourceDisplay } ) => sortFn ( ts . displayPartsToString ( sourceDisplay ) ) , entriesToSort ) )
37
+ entries . splice ( i , 0 , ...sortBy ( ( { sourceDisplay } ) => sortFn ( ts . displayPartsToString ( sourceDisplay ) ) , entriesToSort ) )
37
38
}
38
- return newEntries
39
+ return entries
39
40
}
0 commit comments