@@ -15,6 +15,7 @@ import switchCaseExcludeCovered from './completions/switchCaseExcludeCovered'
15
15
import additionalTypesSuggestions from './completions/additionalTypesSuggestions'
16
16
import boostKeywordSuggestions from './completions/boostKeywordSuggestions'
17
17
import boostTextSuggestions from './completions/boostNameSuggestions'
18
+ import keywordsSpace from './completions/keywordsSpace'
18
19
19
20
export type PrevCompletionMap = Record < string , { originalName ?: string ; documentationOverride ?: string | ts . SymbolDisplayPart [ ] } >
20
21
@@ -48,6 +49,7 @@ export const getCompletionsAtPosition = (
48
49
/** node that is one character behind
49
50
* useful as in most cases we work with node that is behind the cursor */
50
51
const leftNode = findChildContainingPosition ( ts , sourceFile , position - 1 )
52
+ const tokenAtPosition = tsFull . getTokenAtPosition ( sourceFile as any , position ) as ts . Node
51
53
if ( [ '.jsx' , '.tsx' ] . some ( ext => fileName . endsWith ( ext ) ) ) {
52
54
// #region JSX tag improvements
53
55
if ( node ) {
@@ -158,34 +160,7 @@ export const getCompletionsAtPosition = (
158
160
} )
159
161
160
162
if ( c ( 'suggestions.keywordsInsertText' ) === 'space' ) {
161
- const charAhead = scriptSnapshot . getText ( position , position + 1 )
162
- const bannedKeywords = [
163
- 'true' ,
164
- 'false' ,
165
- 'undefined' ,
166
- 'null' ,
167
- 'never' ,
168
- 'unknown' ,
169
- 'any' ,
170
- 'symbol' ,
171
- 'string' ,
172
- 'number' ,
173
- 'boolean' ,
174
- 'object' ,
175
- 'this' ,
176
- 'catch' ,
177
- 'constructor' ,
178
- 'continue' ,
179
- 'break' ,
180
- 'debugger' ,
181
- 'default' ,
182
- 'super' ,
183
- 'import' ,
184
- ]
185
- prior . entries = prior . entries . map ( entry => {
186
- if ( entry . kind !== ts . ScriptElementKind . keyword || charAhead === ' ' || bannedKeywords . includes ( entry . name ) ) return entry
187
- return { ...entry , insertText : `${ entry . name } ` }
188
- } )
163
+ prior . entries = keywordsSpace ( prior . entries , scriptSnapshot , position , tokenAtPosition )
189
164
}
190
165
191
166
if ( leftNode && c ( 'switchExcludeCoveredCases' ) ) prior . entries = switchCaseExcludeCovered ( prior . entries , position , sourceFile , leftNode ) ?? prior . entries
0 commit comments