-
Notifications
You must be signed in to change notification settings - Fork 228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Array item properties are created with the wrong indent #192
Array item properties are created with the wrong indent #192
Comments
I had the same problem. |
@JPinkney should we submit a PR? |
@squillace Yes preferably |
hi @itowlson , I have a different result using the latest vscode and RH-yaml on marketplace, did I misunderstand something? |
@andxu You're definitely getting the output we want. Could you post your schema or a screenshot of your schema please? It's disappearing too quickly for me to read it off the GIF - sorry. |
{
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"installStep": {
"properties": {
"helm": {
"additionalProperties": false,
"properties": {
"name": {
"type": "string"
}
},
"required": [
"name"
],
"type": "object"
}
},
"required": [
"helm"
],
"type": "object"
}
},
"properties": {
"install": {
"items": {
"anyOf": [
{
"$ref": "#/definitions/installStep"
}
]
},
"type": "array"
}
},
"type": "object"
} |
@andxu That looks right for the repro. Let me check I'm up to date with everything and try again. Thanks! |
@andxu I'm on VS Code 1.36.1 and YAML 0.4.1. Those both look up to date to me. And I pasted your schema into my schema content callback. But I'm still seeing the problem. I wonder what's different between our two environments? @JohannLai I saw you thumbs-upped Andy's schema - is that working for you, or still giving the same problem? |
@andxu I noticed your entries are indented by 4 whereas mine are indented by 2. I am clutching at straws here, but are you using tabs or spaces? Where is your indent configured? |
@andxu If I switch to tabs I get the desired behaviour as shown in your GIF (except for a wiggly saying 'tabs can lead to unpredictable results'). Could you try switching to spaces and see if that reproduces the error for you please? |
@andxu The plot thickens. It's not tabs vs. spaces. It's indent size 2 vs. indent size 4. I have indent size 2, and get the misalignment. If I change it to 4, everything works. (And if I use tabs, but with a size of 2, it goes wrong again.) |
I'm not sure it works. I think it's worth a try. I'll try it later. |
@andxu @squillace got confused about which indent I was referring to because apparently the YAML extension has tab conversion stuff of its own, so for avoidance of doubt it is this one - works when set to 4, shows the bug when set to 2. No YAML-extension-specific settings in play. |
Looks funny, I will test it on different indents to figure out the root cause. |
:-) Thanks, @andxu, thanks so much for tolerated us. :-) Let us know what you find! |
When this plugin provides completion text for the sample yaml below, the snippet vscode-yaml provides is
|
@andxu Thanks for the update. I wonder if it’s also worth looking at what is different about the case where the array item type is specific instead of an anyOf - per the initial bug report, this caused the FIRST array element to indent correctly even with an indent if 2... but still got it wrong on subsequent elements... |
The indent settings in vscode will cause the spaces(if you don't use 'space' other than 'tab') added at the # indent 1
install:
- helm:
^name: # indent 2
install:
- helm:
^^name: # indent 3
install:
- helm:
^^^name: # indent 4
install:
- helm:
^^^^name: as the test case, if the start of helm is far away from slash, indents 4 will also fail: install:
- hel<HIT TAB TO AUTOCOMPLETE> will result in
|
So I think it is a bug in yaml language server generating the snippet at the wrong indent on array objects. |
I will post a PR before 08/05. |
#172) * Fix issue: Array item properties are created with the wrong indent #redhat-developer/vscode-yaml#192 Signed-off-by: andxu <[email protected]>
once the yaml LS is published at npm, I will update the vscode-yaml here. |
thank @JPinkney for publish a new version. |
Looks that that can be reproduced without this extension installed
after re-indent lines
|
I have a JSON schema which contains an array property. The array item type is an object with properties. The desired layout is like this:
When I add the array using tab-completion, RH YAML correctly inserts a starting array
element with the correct indentation:
But when I add a second array element by tab-completing the name, it does not indent the sub-properties:
Furthermore, our real scenario is that the array can contain multiple different kinds of item (which is why we have the
helm
parent name rather than just an array of tuples). So our JSON schema specifies"items": { "anyOf": [ { "$ref": "...helm..." }, { "$ref": "...exec..." }, ... ] }
. In this case, even with only a single option in the "anyOf", no element is auto inserted (correctly, as RH YAML could not know which of the anyOf options to take), and the user must explicitly insert the first array element, which is then indented incorrectlyHere is the simplified JSON Schema which I used to reproduce the issue:
Note that this is the ‘anyOf’ schema to show the second part of the issue (which is our real environment). To reproduce the first part of the issue, remove the
anyOf
from around the$ref
in theitems
schema (or I can send you that schema too).Please let me know if you need any more information.
The text was updated successfully, but these errors were encountered: