Skip to content

Commit 74408ba

Browse files
committed
guide users of the Auto Rename Tag extension to the new editor.renameOnType setting. Fixes microsoft#97700
1 parent 1b9cd97 commit 74408ba

1 file changed

Lines changed: 27 additions & 4 deletions

File tree

  • extensions/html-language-features/client/src

extensions/html-language-features/client/src/htmlMain.ts

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import * as nls from 'vscode-nls';
99
const localize = nls.loadMessageBundle();
1010

1111
import {
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';
1616
import {
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+
4450
interface 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

295318
function getPackageInfo(context: ExtensionContext): IPackageInfo | null {

0 commit comments

Comments
 (0)