Autocomplete bug for HTML attributes in LWC

Issue #2101 resolved
Matej Mercina created an issue

When using autocomplete function when an attribute on an HTML element already has quotes, produces double quotes. See image below for example.

Comments (2)

  1. Scott Wells repo owner

    Yes, this is an unfortunate limitation in how this very specific aspect of the IDE's underlying code completion works when you're extending the set of HTML/XML elements, attributes, and attribute values. The method that gets called to get the enumerated values for the current attribute doesn't provide any type of editor context, specifically whether the caret is already inside of a quoted attributed value. As a result, the enumerated value completions are offered with surrounding quotes based on the HTML code style Generated quote marks configuration.

    This works really great when you're filling in attribute values as your typing the elements and attributes, but as you've pointed out here, it falls flat when you're using code completion to change the value for an existing attribute that is constrained by an enumerated list of values.

  2. Scott Wells repo owner

    Resolving..albeit unhappily on my part...because I've wrestled with this a few times trying to figure out a good way to determine whether surrounding quotes should be included or not, and unfortunately there's just not a 100% deterministic way to do so that doesn't require parsing the entire surrounding document which is too expensive in the surrounding operation.

  3. Log in to comment