@@ -45,6 +45,7 @@ import {
4545 isKitTypePath ,
4646 isPartOfImportStatement
4747} from './utils' ;
48+ import { isInTag as svelteIsInTag } from '../svelte-ast-utils' ;
4849
4950export interface CompletionEntryWithIdentifier extends ts . CompletionEntry , TextDocumentIdentifier {
5051 position : Position ;
@@ -258,9 +259,12 @@ export class CompletionsProviderImpl implements CompletionsProvider<CompletionEn
258259 ) ;
259260 }
260261
262+ // moved here due to perf reasons
261263 const existingImports = this . getExistingImports ( document ) ;
262264 const wordRangeStartPosition = document . positionAt ( wordRange . start ) ;
263- const fileUrl = pathToUrl ( tsDoc . filePath ) ; // moved here due to perf reasons
265+ const fileUrl = pathToUrl ( tsDoc . filePath ) ;
266+ const isCompletionInTag = svelteIsInTag ( svelteNode , originalOffset ) ;
267+
264268 const completionItems = completions
265269 . filter ( isValidCompletion ( document , position , ! ! tsDoc . parserError ) )
266270 . map ( ( comp ) =>
@@ -269,6 +273,7 @@ export class CompletionsProviderImpl implements CompletionsProvider<CompletionEn
269273 comp ,
270274 fileUrl ,
271275 position ,
276+ isCompletionInTag ,
272277 addCommitCharacters ,
273278 existingImports
274279 )
@@ -420,6 +425,7 @@ export class CompletionsProviderImpl implements CompletionsProvider<CompletionEn
420425 comp : ts . CompletionEntry ,
421426 uri : string ,
422427 position : Position ,
428+ isCompletionInTag : boolean ,
423429 addCommitCharacters : boolean ,
424430 existingImports : Set < string >
425431 ) : AppCompletionItem < CompletionEntryWithIdentifier > | null {
@@ -428,13 +434,23 @@ export class CompletionsProviderImpl implements CompletionsProvider<CompletionEn
428434 return null ;
429435 }
430436
431- const { label, insertText, isSvelteComp, replacementSpan } = completionLabelAndInsert ;
437+ let { label, insertText, isSvelteComp, replacementSpan } = completionLabelAndInsert ;
432438 // TS may suggest another Svelte component even if there already exists an import
433439 // with the same name, because under the hood every Svelte component is postfixed
434440 // with `__SvelteComponent`. In this case, filter out this completion by returning null.
435441 if ( isSvelteComp && existingImports . has ( label ) ) {
436442 return null ;
437443 }
444+ // Remove wrong quotes, for example when using --css-props
445+ if (
446+ isCompletionInTag &&
447+ ! insertText &&
448+ label [ 0 ] === '"' &&
449+ label [ label . length - 1 ] === '"'
450+ ) {
451+ label = label . slice ( 1 , - 1 ) ;
452+ }
453+
438454 const textEdit = replacementSpan
439455 ? TextEdit . replace ( convertRange ( snapshot , replacementSpan ) , insertText ?? label )
440456 : undefined ;
0 commit comments