From c5d3ad08f0e64cf11cf12e3d5607c5048e9fd7bd Mon Sep 17 00:00:00 2001 From: Stephen Sigwart Date: Wed, 18 Aug 2021 21:20:50 -0400 Subject: [PATCH] Switch to settings.html.completion.attributeDefaultValue --- .../html-language-features/package.json | 22 ++++++++++++++----- .../html-language-features/package.nls.json | 5 ++++- .../server/src/modes/htmlMode.ts | 8 ++++--- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/extensions/html-language-features/package.json b/extensions/html-language-features/package.json index a4e46fccd11..f6cd594963f 100644 --- a/extensions/html-language-features/package.json +++ b/extensions/html-language-features/package.json @@ -38,6 +38,22 @@ "type": "object", "title": "HTML", "properties": { + "html.completion.attributeDefaultValue": { + "type": "string", + "scope": "resource", + "enum": [ + "doubleQuotes", + "singleQuotes", + "empty" + ], + "enumDescriptions": [ + "%html.completion.attributeDefaultValue.doubleQuotes%", + "%html.completion.attributeDefaultValue.singleQuotes%", + "%html.completion.attributeDefaultValue.empty%" + ], + "default": "doubleQuotes", + "description": "%html.completion.attributeDefaultValue%" + }, "html.customData": { "type": "array", "markdownDescription": "%html.customData.desc%", @@ -188,12 +204,6 @@ "default": true, "description": "%html.autoClosingTags%" }, - "html.doNotAddAttributeQuotes": { - "type": "boolean", - "scope": "resource", - "default": false, - "description": "%html.doNotAddAttributeQuotes%" - }, "html.hover.documentation": { "type": "boolean", "scope": "resource", diff --git a/extensions/html-language-features/package.nls.json b/extensions/html-language-features/package.nls.json index ca39247b8f9..18397b1d577 100644 --- a/extensions/html-language-features/package.nls.json +++ b/extensions/html-language-features/package.nls.json @@ -28,7 +28,10 @@ "html.validate.scripts": "Controls whether the built-in HTML language support validates embedded scripts.", "html.validate.styles": "Controls whether the built-in HTML language support validates embedded styles.", "html.autoClosingTags": "Enable/disable autoclosing of HTML tags.", - "html.doNotAddAttributeQuotes": "Controls whether quotes are automatically added when completing an attribute.", + "html.completion.attributeDefaultValue": "Controls the default value for attributes when completion is accepted.", + "html.completion.attributeDefaultValue.doubleQuotes": "Attribute value is set to \"\".", + "html.completion.attributeDefaultValue.singleQuotes": "Attribute value is set to ''.", + "html.completion.attributeDefaultValue.empty": "Attribute value is not set.", "html.mirrorCursorOnMatchingTag": "Enable/disable mirroring cursor on matching HTML tag.", "html.mirrorCursorOnMatchingTagDeprecationMessage": "Deprecated in favor of `editor.linkedEditing`", "html.hover.documentation": "Show tag and attribute documentation in hover.", diff --git a/extensions/html-language-features/server/src/modes/htmlMode.ts b/extensions/html-language-features/server/src/modes/htmlMode.ts index 437ab27fbb0..8b5a3d4548d 100644 --- a/extensions/html-language-features/server/src/modes/htmlMode.ts +++ b/extensions/html-language-features/server/src/modes/htmlMode.ts @@ -26,9 +26,11 @@ export function getHTMLMode(htmlLanguageService: HTMLLanguageService, workspace: if (doAutoComplete) { options.hideAutoCompleteProposals = true; } - let doNotAddAttributeQuotes = settings && settings.html && settings.html.doNotAddAttributeQuotes; - if (doNotAddAttributeQuotes) { - options.doNotAddAttributeQuotes = true; + let attributeDefaultValue = settings && settings.html && settings.html.completion.attributeDefaultValue; + if (attributeDefaultValue === 'empty') { + options.useEmptyAttrValue = true; + } else if (attributeDefaultValue === 'singleQuotes') { + options.useSingleQuotesForAttrs = true; } const htmlDocument = htmlDocuments.get(document);