Add setting to disable end tag suggestions #219
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #216
Summary
This PR introduces a new
hideEndTagSuggestions
configuration option that allows users to disable closing tag suggestions in HTML completions.Related Changes
Problem
Currently, the
html.suggest.html5
setting controls whether HTML5 tags, properties, and values are suggested, but it does not affect closing tag suggestions (e.g.,</div>
). When a user types<
in an HTML document, they see both regular tag suggestions and end tag completions for unclosed tags.Users who want to disable all HTML suggestions have no way to turn off these end tag completions without disabling the entire extension. This is particularly important for users of alternative HTML tools (like SuperHTML mentioned in the issue) who want to use VS Code's editor features but prefer to use a different tool for HTML completions.
Solution
This PR adds a new
hideEndTagSuggestions
boolean option to theCompletionConfiguration
interface. When set totrue
, the language service will not provide end tag suggestions.Changes Made
vscode-html-languageservice
hideEndTagSuggestions?: boolean
to theCompletionConfiguration
interfacecollectCloseTagSuggestions
function to check the setting and return early if disabledvscode (VS Code Extension) microsoft/vscode#269605
html.suggest.hideEndTagSuggestions
with default valuefalse
Testing
The implementation includes comprehensive test coverage:
hideEndTagSuggestions: true
, no end tag suggestions appearhtml5: false
)All existing tests continue to pass, ensuring backward compatibility.
Backward Compatibility
The setting defaults to
false
, meaning end tag suggestions are shown by default. This maintains the current behavior for all existing users. Only users who explicitly enable this setting will see the change in behavior.Usage
Users can add this to their VS Code settings to disable end tag suggestions:
This can be combined with disabling HTML5 suggestions for a minimal suggestion experience: