Skip to content

Completions ignore maxOccurs restriction #1747

@fflaten

Description

@fflaten

Completions does not filter elements based on maxOccurs when triggering completion above the existing elements. See example below.

The schema validation will fail as expected when the duplicate exists, but we should not get the suggestion in the first place.

Example:

# repro.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
  elementFormDefault="qualified">

  <xs:element name="Demo">
    <xs:complexType>
      <xs:all>
        <xs:element name="Hello" type="xs:string" minOccurs="0" />
        <xs:element name="World" type="xs:string" minOccurs="0" maxOccurs="1" />
      </xs:all>
    </xs:complexType>
  </xs:element>
</xs:schema>

# issue.xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Demo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:noNamespaceSchemaLocation="repro.xsd">
    <!-- Trigger completions above Hello: Will get completion for both Hello and World -->
    <Hello></Hello>
    <!-- Trigger completions above World: Will get completion World -->
    <World></World>
    <!-- Trigger completions below World: No completions as expected -->
</Demo>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions