@@ -116,8 +116,6 @@ export function create({
116
116
} ;
117
117
useDefaultDataProvider ?: boolean ;
118
118
isFormattingEnabled ?( document : TextDocument , context : LanguageServiceContext ) : ProviderResult < boolean > ;
119
- isAutoCreateQuotesEnabled ?( document : TextDocument , context : LanguageServiceContext ) : ProviderResult < boolean > ;
120
- isAutoClosingTagsEnabled ?( document : TextDocument , context : LanguageServiceContext ) : ProviderResult < boolean > ;
121
119
getDocumentContext ?( context : LanguageServiceContext ) : html . DocumentContext ;
122
120
getFormattingOptions ?( document : TextDocument , options : FormattingOptions , context : LanguageServiceContext ) : ProviderResult < html . HTMLFormatConfiguration > ;
123
121
getCompletionConfiguration ?( document : TextDocument , context : LanguageServiceContext ) : ProviderResult < html . CompletionConfiguration | undefined > ;
@@ -370,36 +368,26 @@ export function create({
370
368
} ) ;
371
369
} ,
372
370
373
- async provideAutoInsertSnippet ( document , selection , change ) {
371
+ async provideAutoInsertSnippet ( document , selection , lastChange ) {
374
372
// selection must at end of change
375
- if ( document . offsetAt ( selection ) !== change . rangeOffset + change . text . length ) {
373
+ if ( document . offsetAt ( selection ) !== lastChange . rangeOffset + lastChange . text . length ) {
376
374
return ;
377
375
}
378
376
return worker ( document , async htmlDocument => {
379
- if ( change . rangeLength === 0 && change . text . endsWith ( '=' ) ) {
380
-
381
- const enabled = await context . env . getConfiguration ?.( configurationSections . autoCreateQuotes ) ?? true ;
382
-
383
- if ( enabled ) {
384
-
385
- const completionConfiguration = await getCompletionConfiguration ( document , context ) ;
386
- const text = htmlLs . doQuoteComplete ( document , selection , htmlDocument , completionConfiguration ) ;
387
-
388
- if ( text ) {
389
- return text ;
377
+ if ( lastChange . rangeLength === 0 && ! / \n / . test ( lastChange . text ) ) {
378
+ if ( lastChange . text . endsWith ( '=' ) ) {
379
+ const enabled = await context . env . getConfiguration ?.( configurationSections . autoCreateQuotes ) ?? true ;
380
+ if ( enabled ) {
381
+ const completionConfiguration = await getCompletionConfiguration ( document , context ) ;
382
+ const text = htmlLs . doQuoteComplete ( document , selection , htmlDocument , completionConfiguration ) ;
383
+ return text ?? undefined ;
390
384
}
391
385
}
392
- }
393
- if ( change . rangeLength === 0 && ( change . text . endsWith ( '>' ) || change . text . endsWith ( '/' ) ) ) {
394
-
395
- const enabled = await context . env . getConfiguration ?.( configurationSections . autoClosingTags ) ?? true ;
396
-
397
- if ( enabled ) {
398
-
399
- const text = htmlLs . doTagComplete ( document , selection , htmlDocument ) ;
400
-
401
- if ( text ) {
402
- return text ;
386
+ if ( lastChange . text . endsWith ( '>' ) || lastChange . text . endsWith ( '/' ) ) {
387
+ const enabled = await context . env . getConfiguration ?.( configurationSections . autoClosingTags ) ?? true ;
388
+ if ( enabled ) {
389
+ const text = htmlLs . doTagComplete ( document , selection , htmlDocument ) ;
390
+ return text ?? undefined ;
403
391
}
404
392
}
405
393
}
0 commit comments