@@ -6,24 +6,25 @@ import { sortBy } from 'rambda'
66export default ( entries : ts . CompletionEntry [ ] , languageService : ts . LanguageService , c : GetConfig ) => {
77 const ignoreAutoImportsSetting = getIgnoreAutoImportSetting ( c )
88
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
1112 const targetModule = ts . displayPartsToString ( sourceDisplay )
1213 const toIgnore = isAutoImportEntryShouldBeIgnored ( ignoreAutoImportsSetting , targetModule , name )
1314 return ! toIgnore
1415 } )
1516 // todo I'm not sure of incomplete completion (wasnt tested)
1617 // todo don't forget to impl glob there
1718 const handledSymbolNames = new Set < string > ( )
18- for ( const [ i , entry ] of newEntries . entries ( ) ) {
19+ for ( const [ i , entry ] of entries . entries ( ) ) {
1920 const { name } = entry
2021 if ( ! entry . sourceDisplay || handledSymbolNames . has ( name ) ) continue
2122 if ( ! shouldChangeSortingOfAutoImport ( name , c ) ) continue
2223 handledSymbolNames . add ( name )
2324 const sortFn = changeSortingOfAutoImport ( c , name )
2425 // TODO probably should be rewrited
2526 const entriesToSort : ts . CompletionEntry [ ] = [ ]
26- newEntries = newEntries . filter ( ( entry , k ) => {
27+ entries = entries . filter ( ( entry , k ) => {
2728 if ( k < i ) return true
2829 if ( entry . sourceDisplay && entry . name === name ) {
2930 entriesToSort . push ( entry )
@@ -33,7 +34,7 @@ export default (entries: ts.CompletionEntry[], languageService: ts.LanguageServi
3334 } )
3435 // todo rewrite outer that for loop to index based and increment here on insert length + handledSymbolNames can be removed in that case
3536 // 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 ) )
3738 }
38- return newEntries
39+ return entries
3940}
0 commit comments