-
Notifications
You must be signed in to change notification settings - Fork 263
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
fix: array item with existing property #882
base: main
Are you sure you want to change the base?
fix: array item with existing property #882
Conversation
@@ -144,11 +144,11 @@ export class YamlCompletion { | |||
|
|||
this.arrayPrefixIndentation = ''; | |||
let overwriteRange: Range = null; | |||
const isOnlyHyphen = lineContent.match(/^\s*(-)\s*$/); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if doing this with RegEx is a good idea. For instance this fails on a line like - # a comment
. Can we use the AST to check if the rest of the line does not have any semantically significant tokens?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it was there from the previous implementation, I just reused it (moved it up). I didn't want to change it.
But agree,
I went a little bit deeper and there is another problem.
The real problem is in getNodeFromPosition
This method doesn't give proper results for arrays and maybe some others. That is the reason why there has to be custom code to 'fix' proper node based on special conditions 'empty lines, arrays, ...' (lines 343 to 515 in yamlCompletion)
for example, this yaml return nodes:
foo:
- # foo object is returned (should be foo[0])
# foo object is returned (should be foo[0])
item1: aaaf
# foo[0] object is returned (OK)
- # foo object is returned (should be foo[1])
# foo[!!0!!] object is returned (should be foo[1])
item2: bbb
# foo[1] object is returned (OK)
So this PR doesn't make sense anymore (it's possible to reuse tests)
Does your team have the capacity to fix it?
If not I will try it in the future, but don't have much time to do it :-/
856cb85
to
3b3dd25
Compare
@gorkem can you please consider this PR it will also fix another issue (see updated description 3) ) I think that but this PR doesn't try to reimplement it, this PR fixes a few issues that are caused by a combination of:
|
d28582f
to
7ca0300
Compare
What does this PR do?
fix autocompletion when the position is on the same line with the hyphen followed by other props
there are two problems:
Screen.Recording.2023-05-17.at.09.38.41.mov
Screen.Recording.2023-05-17.at.09.39.39.mov
after fix of the 1st problem, the 2nd problem looks like this
Screen.Recording.2023-05-17.at.09.57.23.mov
after fix:
Screen.Recording.2023-05-17.at.09.40.47.mov
UPDATE:
3) this PR also fixes this issue:
Screen.Recording.2023-07-17.at.13.04.06.mov
Screen.Recording.2023-11-29.at.13.54.43.mov
What issues does this PR fix or reference?
no reference
Is it tested? How?
add unit tests