Fix array of const completion#1092
Conversation
a3c9464 to
8bb19c6
Compare
|
Taking a look now... |
|
Something's up. I still get the bug from #620. Try running it in vscode-yaml and open completion here: test:
- value1
| |
|
Looking |
|
I guess that makes sense with my change... Sigh, back to the drawing board I go. I will say though - the correction made in the other PR is not the right fix for this, as it breaks enum/const array completion |
|
I agree. Something's up. |
|
When investigating, I found something weird - the closest node discoverer function returns the null value node for when the key is not filled, but returns the map node when the key IS filled. I think my next attempt will be to fix it there. |
|
I think I have an idea for how to fix it - the idea is "if on an empty line && node is null, don't autocomplete scalar values" |
|
That makes sense to me. |
8bb19c6 to
8d9690f
Compare
|
Hey @datho7561 - I think I got it (mostly?) working. It all works in tests BUT theres a weird case where, in your case, it suggests an empty line, but it wants to add it on the wrong indent. Imo thats out of scope for this PR, since I've experienced this before |
|
Wait hold, found issue w/ docs |
|
Scratch previous comments - that was my local env being odd. @datho7561 would you mind taking a look at this PR again? |
datho7561
left a comment
There was a problem hiding this comment.
I tried the updated fix and I still get completions for the const values even if there isn't a - when trying it from within VS Code. I also tried it in Neovim and same thing.
Can you confirm this is the case on your end? Maybe something is off with my environment too.
|
Hey - I'm sorry, I don't think I understand what you mean. Can you share a yaml snippet of where you're getting incorrect completions? |
|
It's the same case I mentioned before that's behaving weird. The schema this file is pointing to is the one you've used in the tests. Open completion where the # yaml-language-server: $schema=./array-of-const.json
test:
- value1
|You get 3 completion results. The first adds We either need to stop the |
|
Ill take a look, thanks for clarifying! |
|
I am able to reproduce this, looks like another leak source, I'll find it |
|
Heya @datho7561 - I got that one fixed as well ^^ - can you try again? |
|
@ShadiestGoat that case still seems to be a bit broken in VS Code. Something's different between the test cases and actually running it in VS Code. That's not a good sign, that probably warrants an investigation (in a separate PR, I can do that). I did some debugging and I think that I figured out a solution; here's what I have: diff --git a/src/languageservice/services/yamlCompletion.ts b/src/languageservice/services/yamlCompletion.ts
index ccfb9d1..f83907b 100644
--- a/src/languageservice/services/yamlCompletion.ts
+++ b/src/languageservice/services/yamlCompletion.ts
@@ -516,8 +516,7 @@ export class YamlCompletion {
const ignoreScalars =
textBuffer.getLineContent(overwriteRange.start.line).trim().length === 0 &&
originalNode &&
- isScalar(originalNode) &&
- originalNode.value === null;
+ ((isScalar(originalNode) && originalNode.value === null) || isSeq(originalNode));
// completion for object keys
if (node && isMap(node)) {
@@ -939,7 +938,7 @@ export class YamlCompletion {
separatorAfter,
collector,
types,
- false,
+ ignoreScalars,
typeof s.schema.items === 'object' &&
(s.schema.items.type === 'object' || isAnyOfAllOfOneOfType(s.schema.items)) |
|
that makes total sense - good catch. I assume this works just because if we are in an empty line & we are in a seq, then we can always ignore scalars. I mean why would we suggest a scalar in an such a case? I can patch this in and test in my evening, thanks for the testing and suggestions! |
dfdbe7c to
8e08cad
Compare
|
Thats weird I'm still getting the same issue |
|
So... I think this is ready to merge! Please let me know if I need to do anything else ^^ |
datho7561
left a comment
There was a problem hiding this comment.
Looks good to me and works well. Thanks, Lucy!





















What does this PR do?
This PR focuses on fixing array of const issues described in redhat-developer/vscode-yaml#879
It also takes care not to regress on the error fixed in #670, but takes a step further in fixing that issue
What issues does this PR fix or reference?
redhat-developer/vscode-yaml#879
#620
Is it tested? How?
Unit tests & client side testing