Skip to content

Conversation

obrobrio2000
Copy link

@obrobrio2000 obrobrio2000 commented Oct 2, 2025

Closes #216

Summary

This PR introduces a new hideEndTagSuggestions configuration option that allows users to disable closing tag suggestions in HTML completions.

Related Changes

⚠️ Important: This PR has corresponding changes in the vscode repository: microsoft/vscode#269605

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 the CompletionConfiguration interface. When set to true, the language service will not provide end tag suggestions.

Changes Made

vscode-html-languageservice

  1. htmlLanguageTypes.ts: Added hideEndTagSuggestions?: boolean to the CompletionConfiguration interface
  2. htmlCompletion.ts: Updated collectCloseTagSuggestions function to check the setting and return early if disabled
  3. completion.test.ts: Added comprehensive tests covering various scenarios with the new setting

vscode (VS Code Extension) microsoft/vscode#269605

  1. package.json: Added new configuration setting html.suggest.hideEndTagSuggestions with default value false
  2. package.nls.json: Added localized description for the new setting

Testing

The implementation includes comprehensive test coverage:

  • Default behavior (end tags shown) remains unchanged
  • When hideEndTagSuggestions: true, no end tag suggestions appear
  • Works correctly in combination with other settings (e.g., html5: false)
  • Tests various contexts: nested tags, indented tags, and standalone close tags

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
}

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 <[email protected]>
@Copilot Copilot AI review requested due to automatic review settings October 2, 2025 19:59
Copy link

@Copilot Copilot AI left a 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 hideEndTagSuggestions boolean field to the CompletionConfiguration interface
  • Modified collectCloseTagSuggestions function 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Setting to disable end tag suggestions
1 participant