@@ -20,6 +20,7 @@ import defaultHelpers from './completions/defaultHelpers'
20
20
import objectLiteralCompletions from './completions/objectLiteralCompletions'
21
21
import filterJsxElements from './completions/filterJsxComponents'
22
22
import markOrRemoveGlobalCompletions from './completions/markOrRemoveGlobalCompletions'
23
+ import { oneOf } from '@zardoy/utils'
23
24
24
25
export type PrevCompletionMap = Record < string , { originalName ?: string ; documentationOverride ?: string | ts . SymbolDisplayPart [ ] } >
25
26
@@ -92,11 +93,50 @@ export const getCompletionsAtPosition = (
92
93
93
94
if ( ! prior ) return
94
95
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
+
95
130
if ( c ( 'fixSuggestionsSorting' ) ) prior . entries = fixPropertiesSorting ( prior . entries , leftNode , sourceFile , program ) ?? prior . entries
96
131
if ( node ) prior . entries = boostKeywordSuggestions ( prior . entries , position , node ) ?? prior . entries
97
132
98
133
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
+ }
100
140
if ( [ 'bind' , 'call' , 'caller' ] . every ( name => entryNames . has ( name ) ) && c ( 'highlightNonFunctionMethods.enable' ) ) {
101
141
const standardProps = new Set ( [ 'Symbol' , 'apply' , 'arguments' , 'bind' , 'call' , 'caller' , 'length' , 'name' , 'prototype' , 'toString' ] )
102
142
// TODO lift up!
0 commit comments