@@ -9,9 +9,9 @@ import * as nls from 'vscode-nls';
99const localize = nls . loadMessageBundle ( ) ;
1010
1111import {
12- languages , ExtensionContext , IndentAction , Position , TextDocument , Range , CompletionItem , CompletionItemKind , SnippetString , workspace ,
12+ languages , ExtensionContext , IndentAction , Position , TextDocument , Range , CompletionItem , CompletionItemKind , SnippetString , workspace , extensions ,
1313 Disposable , FormattingOptions , CancellationToken , ProviderResult , TextEdit , CompletionContext , CompletionList , SemanticTokensLegend ,
14- DocumentSemanticTokensProvider , DocumentRangeSemanticTokensProvider , SemanticTokens
14+ DocumentSemanticTokensProvider , DocumentRangeSemanticTokensProvider , SemanticTokens , window , commands
1515} from 'vscode' ;
1616import {
1717 LanguageClient , LanguageClientOptions , ServerOptions , TransportKind , RequestType , TextDocumentPositionParams , DocumentRangeFormattingParams ,
@@ -41,6 +41,12 @@ namespace SemanticTokenLegendRequest {
4141 export const type : RequestType0 < { types : string [ ] ; modifiers : string [ ] } | null , any , any > = new RequestType0 ( 'html/semanticTokenLegend' ) ;
4242}
4343
44+ namespace SettingIds {
45+ export const renameOnType = 'editor.renameOnType' ;
46+ export const formatEnable = 'html.format.enable' ;
47+
48+ }
49+
4450interface IPackageInfo {
4551 name : string ;
4652 version : string ;
@@ -140,7 +146,7 @@ export function activate(context: ExtensionContext) {
140146 // manually register / deregister format provider based on the `html.format.enable` setting avoiding issues with late registration. See #71652.
141147 updateFormatterRegistration ( ) ;
142148 toDispose . push ( { dispose : ( ) => rangeFormatting && rangeFormatting . dispose ( ) } ) ;
143- toDispose . push ( workspace . onDidChangeConfiguration ( e => e . affectsConfiguration ( 'html.format.enable' ) && updateFormatterRegistration ( ) ) ) ;
149+ toDispose . push ( workspace . onDidChangeConfiguration ( e => e . affectsConfiguration ( SettingIds . formatEnable ) && updateFormatterRegistration ( ) ) ) ;
144150
145151 client . sendRequest ( SemanticTokenLegendRequest . type ) . then ( legend => {
146152 if ( legend ) {
@@ -180,7 +186,7 @@ export function activate(context: ExtensionContext) {
180186 } ) ;
181187
182188 function updateFormatterRegistration ( ) {
183- const formatEnabled = workspace . getConfiguration ( ) . get ( 'html.format.enable' ) ;
189+ const formatEnabled = workspace . getConfiguration ( ) . get ( SettingIds . formatEnable ) ;
184190 if ( ! formatEnabled && rangeFormatting ) {
185191 rangeFormatting . dispose ( ) ;
186192 rangeFormatting = undefined ;
@@ -290,6 +296,23 @@ export function activate(context: ExtensionContext) {
290296 return results ;
291297 }
292298 } ) ;
299+
300+ const promptForTypeOnRenameKey = 'html.promptForTypeOnRename' ;
301+ const promptForTypeOnRename =
302+ ! workspace . getConfiguration ( ) . get ( SettingIds . renameOnType , { languageId : 'html' } ) &&
303+ extensions . getExtension ( 'formulahendry.auto-rename-tag' ) &&
304+ ( context . globalState . get ( promptForTypeOnRenameKey ) !== false ) ;
305+
306+ toDispose . push ( window . onDidChangeActiveTextEditor ( async e => {
307+ if ( e && promptForTypeOnRename && documentSelector . indexOf ( e . document . languageId ) !== - 1 ) {
308+ context . globalState . update ( promptForTypeOnRenameKey , false ) ;
309+ const configure = localize ( 'configureButton' , 'Configure' ) ;
310+ const res = await window . showInformationMessage ( localize ( 'renameOnTypeQuestion' , 'VS Code now has built-in support for auto-renaming tags. Do you want to enable it?' ) , configure ) ;
311+ if ( res === configure ) {
312+ commands . executeCommand ( 'workbench.action.openSettings' , SettingIds . renameOnType ) ;
313+ }
314+ }
315+ } ) ) ;
293316}
294317
295318function getPackageInfo ( context : ExtensionContext ) : IPackageInfo | null {
0 commit comments