Skip to content

Completion textEdit range incorrect for paths with additionalProperties #838

@fecet

Description

@fecet

Description

When completing TOML table headers that involve additionalProperties in the JSON schema, Taplo returns incorrect textEdit.range values. The range covers the entire table header path, but the replacement text is only the leaf property name.

Steps to Reproduce

  1. Use a schema like pixi's manifest schema where feature uses additionalProperties:

    "feature": {
      "type": "object",
      "additionalProperties": {
        "$ref": "#/$defs/Feature"
      }
    }

    And Feature has properties like pypi-dependencies.

  2. In a TOML file, type [feature.ci. and trigger completion

  3. Select pypi-dependencies from completion

  4. Expected: [feature.ci.pypi-dependencies]
    Actual: [pypi-dependencies] (the feature.ci. prefix is replaced/deleted)

Root Cause Analysis

Taplo returns a textEdit like:

{
  "range": { "start": { "character": 1 }, "end": { "character": 12 } },
  "newText": "pypi-dependencies"
}

The range covers feature.ci. (cols 1-12), but newText is only pypi-dependencies. This causes editors to replace the entire path with just the leaf name.

Schema Path Comparison

Path Schema Definition Completion
activation.scripts Direct $ref ✅ Works
feature.ci.pypi-dependencies additionalProperties$ref ❌ Broken

The issue appears specific to paths that traverse through additionalProperties (dynamic keys).

Environment

Related

  • blink.cmp#2343 - Initially reported there, confirmed to be upstream Taplo issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions