-
Notifications
You must be signed in to change notification settings - Fork 125
Add setting to disable end tag suggestions #219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add setting to disable end tag suggestions #219
Conversation
Fixes microsoft#216 This change introduces a new `hideEndTagSuggestions` configuration option in the CompletionConfiguration interface that allows users to disable closing tag suggestions in HTML completions. Previously, the `html.suggest.html5` setting controlled whether HTML5 tags, properties, and values were suggested, but it did not affect closing tag suggestions (e.g., `</div>`). Users who wanted to disable the extension's suggestions entirely had no way to turn off these end tag completions without disabling the entire extension. Changes: - Added `hideEndTagSuggestions?: boolean` to the CompletionConfiguration interface in htmlLanguageTypes.ts - Updated the `collectCloseTagSuggestions` function in htmlCompletion.ts to check this setting and return early if end tag suggestions are disabled - Added comprehensive tests to verify the setting works correctly in various scenarios The setting defaults to `false` (showing end tag suggestions) to maintain backward compatibility with existing behavior. Signed-off-by: Giovanni Magliocchetti <giovimag123@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a new configuration option hideEndTagSuggestions that allows users to disable closing tag suggestions (e.g., </div>) in HTML completions while keeping other HTML suggestions active.
- Added
hideEndTagSuggestionsboolean field to theCompletionConfigurationinterface - Modified
collectCloseTagSuggestionsfunction to return early when the setting is enabled - Added comprehensive test coverage for the new functionality in various contexts
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/htmlLanguageTypes.ts | Added hideEndTagSuggestions optional boolean field to CompletionConfiguration interface |
| src/services/htmlCompletion.ts | Added early return in collectCloseTagSuggestions when hideEndTagSuggestions is enabled |
| src/test/completion.test.ts | Added comprehensive test cases covering default behavior, setting enabled, and various contexts |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
@copilot Looks good! Can you also add an entry to CHANGELOG.md? The upcoming version is going to be 5.6.0 |
|
@copilot Can you also add an entry to CHANGELOG.md? The upcoming version is going to be 5.6.0 |
|
@obrobrio2000 No worries, all good, thanks for your help! |
Closes #216
Summary
This PR introduces a new
hideEndTagSuggestionsconfiguration option that allows users to disable closing tag suggestions in HTML completions.Related Changes
Problem
Currently, the
html.suggest.html5setting 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
hideEndTagSuggestionsboolean option to theCompletionConfigurationinterface. When set totrue, the language service will not provide end tag suggestions.Changes Made
vscode-html-languageservice
hideEndTagSuggestions?: booleanto theCompletionConfigurationinterfacecollectCloseTagSuggestionsfunction to check the setting and return early if disabledvscode (VS Code Extension) microsoft/vscode#269605
html.suggest.hideEndTagSuggestionswith default valuefalseTesting
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:
{ "html.suggest.hideEndTagSuggestions": true }This can be combined with disabling HTML5 suggestions for a minimal suggestion experience:
{ "html.suggest.html5": false, "html.suggest.hideEndTagSuggestions": true }