diff --git a/typescript/src/completions/jsxAttributes.ts b/typescript/src/completions/jsxAttributes.ts index 976b821..3eceb5b 100644 --- a/typescript/src/completions/jsxAttributes.ts +++ b/typescript/src/completions/jsxAttributes.ts @@ -11,6 +11,7 @@ export default ( sourceFile: ts.SourceFile, jsxCompletionsMap: Configuration['jsxCompletionsMap'], ): ts.CompletionEntry[] => { + const originalNode = node // ++ patch with jsxCompletionsMap // -- don't // { if (locals.includes(entry.name)) { const insertText = `${entry.name}={${entry.name}}` - const additionalSuggestions = { + const pos = attrib ? attrib.end - attrib.getWidth() : 0 + const additionalSuggestions: ts.CompletionEntry = { ...entry, name: insertText, insertText, + replacementSpan: attrib + ? { + start: pos, + length: attrib.end - pos, + } + : undefined, } return enableJsxAttributesShortcuts === 'after' ? [entry, additionalSuggestions] : [additionalSuggestions, entry] }