[html] update auto-rename-tag to linkedEditing migration

This commit is contained in:
Martin Aeschlimann 2021-01-06 15:49:00 +01:00
parent 4fe3f75c6d
commit c49ef6df61

View file

@ -40,7 +40,7 @@ namespace SemanticTokenLegendRequest {
}
namespace SettingIds {
export const linkedRename = 'editor.linkedRename';
export const linkedEditing = 'editor.linkedEditing';
export const formatEnable = 'html.format.enable';
}
@ -284,25 +284,25 @@ export function startClient(context: ExtensionContext, newLanguageClient: Langua
}
});
const promptForTypeOnRenameKey = 'html.promptForTypeOnRename';
const promptForTypeOnRename = extensions.getExtension('formulahendry.auto-rename-tag') !== undefined &&
(context.globalState.get(promptForTypeOnRenameKey) !== false) &&
!workspace.getConfiguration('editor', { languageId: 'html' }).get('linkedRename');
if (promptForTypeOnRename) {
const activeEditorListener = window.onDidChangeActiveTextEditor(async e => {
if (e && documentSelector.indexOf(e.document.languageId) !== -1) {
context.globalState.update(promptForTypeOnRenameKey, false);
activeEditorListener.dispose();
const configure = localize('configureButton', 'Configure');
const res = await window.showInformationMessage(localize('linkedRenameQuestion', 'VS Code now has built-in support for auto-renaming tags. Do you want to enable it?'), configure);
if (res === configure) {
commands.executeCommand('workbench.action.openSettings', SettingIds.linkedRename);
const promptForLinkedEditingKey = 'html.promptForLinkedEditing';
if (extensions.getExtension('formulahendry.auto-rename-tag') !== undefined && (context.globalState.get(promptForLinkedEditingKey) !== false)) {
const config = workspace.getConfiguration('editor', { languageId: 'html' });
if (!config.get('linkedEditing') && !config.get('renameOnType')) {
const activeEditorListener = window.onDidChangeActiveTextEditor(async e => {
if (e && documentSelector.indexOf(e.document.languageId) !== -1) {
context.globalState.update(promptForLinkedEditingKey, false);
activeEditorListener.dispose();
const configure = localize('configureButton', 'Configure');
const res = await window.showInformationMessage(localize('linkedEditingQuestion', 'VS Code now has built-in support for auto-renaming tags. Do you want to enable it?'), configure);
if (res === configure) {
commands.executeCommand('workbench.action.openSettings', SettingIds.linkedEditing);
}
}
}
});
toDispose.push(activeEditorListener);
});
toDispose.push(activeEditorListener);
}
}
toDispose.push();
}