Skip to content

Commit

Permalink
fix: don't touch banned keywords (they most probably don't need space…
Browse files Browse the repository at this point in the history
… after it). Make default behavior less annoying
  • Loading branch information
zardoy committed Jun 1, 2022
1 parent 8774118 commit a8d830d
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions typescript/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,31 @@ export = function ({ typescript }: { typescript: typeof import('typescript/lib/t

if (c('suggestions.keywordsInsertText') === 'space') {
const charAhead = scriptSnapshot.getText(position, position + 1)
const bannedKeywords = [
'true',
'false',
'undefined',
'null',
'never',
'unknown',
'any',
'symbol',
'string',
'number',
'boolean',
'object',
'this',
'catch',
'constructor',
'continue',
'break',
'debugger',
'default',
'super',
]
prior.entries = prior.entries.map(entry => {
if (entry.kind !== ts.ScriptElementKind.keyword) return entry
entry.insertText = charAhead === ' ' ? entry.name : `${entry.name} `
return entry
if (entry.kind !== ts.ScriptElementKind.keyword || charAhead === ' ' || bannedKeywords.includes(entry.name)) return entry
return { ...entry, insertText: `${entry.name} ` }
})
}

Expand Down

0 comments on commit a8d830d

Please sign in to comment.