Skip to content

Commit a8d830d

Browse files
committed
fix: don't touch banned keywords (they most probably don't need space after it). Make default behavior less annoying
1 parent 8774118 commit a8d830d

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

typescript/src/index.ts

+24-3
Original file line numberDiff line numberDiff line change
@@ -208,10 +208,31 @@ export = function ({ typescript }: { typescript: typeof import('typescript/lib/t
208208

209209
if (c('suggestions.keywordsInsertText') === 'space') {
210210
const charAhead = scriptSnapshot.getText(position, position + 1)
211+
const bannedKeywords = [
212+
'true',
213+
'false',
214+
'undefined',
215+
'null',
216+
'never',
217+
'unknown',
218+
'any',
219+
'symbol',
220+
'string',
221+
'number',
222+
'boolean',
223+
'object',
224+
'this',
225+
'catch',
226+
'constructor',
227+
'continue',
228+
'break',
229+
'debugger',
230+
'default',
231+
'super',
232+
]
211233
prior.entries = prior.entries.map(entry => {
212-
if (entry.kind !== ts.ScriptElementKind.keyword) return entry
213-
entry.insertText = charAhead === ' ' ? entry.name : `${entry.name} `
214-
return entry
234+
if (entry.kind !== ts.ScriptElementKind.keyword || charAhead === ' ' || bannedKeywords.includes(entry.name)) return entry
235+
return { ...entry, insertText: `${entry.name} ` }
215236
})
216237
}
217238

0 commit comments

Comments
 (0)