taplo icon indicating copy to clipboard operation
taplo copied to clipboard

Hover not working on keys whose value is a non-empty array

Open ipkiss42 opened this issue 8 months ago • 1 comments

When using a JSON schema, hovering over a key triggers the LSP "hover" action, which displays the description of that key. However, I noticed that this doesn't work when the value of that key is a non-empty array.

Sample TOML file to reproduce the issue (hover.toml):

# Not an array value: hover on the key works fine
string = "foo"
# Empty array value: hover on the key works fine
empty_array = []
# Non-empty array value: hover on the key is broken
non_empty_array = ["bar"]

Corresponding JSON schema:

{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "title": "Hover Test Schema",
    "description": "A schema to test hover functionality in Taplo",
    "type": "object",
    "properties": {
        "string": {
            "type": "string",
            "description": "A simple string value. Hover on this key should work fine."
        },
        "empty_array": {
            "type": "array",
            "description": "An empty array. Hover on this key should work fine.",
            "items": {
                "type": "string"
            }
        },
        "non_empty_array": {
            "type": "array",
            "description": "A non-empty array. If you see this description when hovering, it means the bug is fixed.",
            "items": {
                "type": "string"
            }
        }
    }
}

I used the following ~/.taplo.toml file to connect the two (adjust the path to the schema accordingly):

[[rule]]
include = ["**/hover.toml"]

[rule.schema]
path = "/path/to/hover-schema.json"

ipkiss42 avatar May 12 '25 14:05 ipkiss42

I just ran into this too - thank you @ipkiss42 for posting the issue and for submitting a fix!

itowlson avatar Jun 06 '25 01:06 itowlson