@@ -20,6 +20,7 @@ import defaultHelpers from './completions/defaultHelpers'
2020import objectLiteralCompletions from './completions/objectLiteralCompletions'
2121import filterJsxElements from './completions/filterJsxComponents'
2222import markOrRemoveGlobalCompletions from './completions/markOrRemoveGlobalCompletions'
23+ import { oneOf } from '@zardoy/utils'
2324
2425export type PrevCompletionMap = Record < string , { originalName ?: string ; documentationOverride ?: string | ts . SymbolDisplayPart [ ] } >
2526
@@ -92,11 +93,50 @@ export const getCompletionsAtPosition = (
9293
9394 if ( ! prior ) return
9495
96+ if ( c ( 'caseSensitiveCompletions' ) ) {
97+ const fullText = sourceFile . getFullText ( )
98+ const currentWord = fullText . slice ( 0 , position ) . match ( / [ \w \d ] + $ / )
99+ if ( currentWord ) {
100+ const firstEnteredChar = fullText . at ( currentWord . index ! ) ?? ''
101+ /** @returns -1 - lowercase, 1 - uppercase, 0 - ignore */
102+ const getCharCasing = ( char : string ) => {
103+ if ( char . toLocaleUpperCase ( ) !== char ) return - 1
104+ if ( char . toLocaleLowerCase ( ) !== char ) return 1
105+ return 0
106+ }
107+ const typedStartCasing = getCharCasing ( firstEnteredChar )
108+ // check wether it is actually a case char and not a number for example
109+ if ( typedStartCasing !== 0 ) {
110+ prior . entries = prior . entries . filter ( entry => {
111+ const entryCasing = getCharCasing ( entry . name . at ( 0 ) ?? '' )
112+ if ( entryCasing === 0 ) return true
113+ return entryCasing === typedStartCasing
114+ } )
115+ }
116+ }
117+ }
118+
119+ if ( c ( 'disableFuzzyCompletions' ) ) {
120+ const fullText = sourceFile . getFullText ( )
121+ const currentWord = fullText . slice ( 0 , position ) . match ( / [ \w \d ] + $ / )
122+ if ( currentWord ) {
123+ prior . entries = prior . entries . filter ( entry => {
124+ if ( entry . name . startsWith ( currentWord [ 0 ] ) ) return true
125+ return false
126+ } )
127+ }
128+ }
129+
95130 if ( c ( 'fixSuggestionsSorting' ) ) prior . entries = fixPropertiesSorting ( prior . entries , leftNode , sourceFile , program ) ?? prior . entries
96131 if ( node ) prior . entries = boostKeywordSuggestions ( prior . entries , position , node ) ?? prior . entries
97132
98133 const entryNames = new Set ( prior . entries . map ( ( { name } ) => name ) )
99- if ( c ( 'removeUselessFunctionProps.enable' ) ) prior . entries = prior . entries . filter ( e => ! [ 'Symbol' , 'caller' , 'prototype' ] . includes ( e . name ) )
134+ if ( c ( 'removeUselessFunctionProps.enable' ) ) {
135+ prior . entries = prior . entries . filter ( entry => {
136+ if ( oneOf ( entry . kind , ts . ScriptElementKind . warning ) ) return true
137+ return ! [ 'Symbol' , 'caller' , 'prototype' ] . includes ( entry . name )
138+ } )
139+ }
100140 if ( [ 'bind' , 'call' , 'caller' ] . every ( name => entryNames . has ( name ) ) && c ( 'highlightNonFunctionMethods.enable' ) ) {
101141 const standardProps = new Set ( [ 'Symbol' , 'apply' , 'arguments' , 'bind' , 'call' , 'caller' , 'length' , 'name' , 'prototype' , 'toString' ] )
102142 // TODO lift up!
0 commit comments