Skip to content
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 completion in the middle of the empty text #697

Conversation

p-spacek
Copy link
Contributor

@p-spacek p-spacek commented Apr 5, 2022

What does this PR do?

fix array completion when the cursor is in the middle of the empty text

before:

array.indent.notok.mov

after:

array.indent.ok.mov

schema for this test

"arrayObj": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "item1": {
            "type": "string"
          },
          "item2": {
            "type": "string",
          }
        },
        "required": [
          "item1",
          "item2"
        ]
      }
    },

What issues does this PR fix or reference?

no ref

Is it tested? How?

added UT,
modified existing one

@@ -2364,10 +2364,44 @@ describe('Auto Completion Tests', () => {
});

const content = 'test:\n - and\n - - ';
const completion = await parseSetup(content, 19);

const completion = await parseSetup(content, 20);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous index 19 is probably not correct. index 20 is the end of the content

@coveralls
Copy link

coveralls commented Apr 5, 2022

Coverage Status

Coverage decreased (-0.1%) to 82.083% when pulling 4df39af on p-spacek:fix/completion-array-in-the-middle-of-the-empty-text into 098496e on redhat-developer:main.

Copy link
Collaborator

@gorkem gorkem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has cases where it does not insert valid YAML

) {
node = nullNode;
originalNode = node;
overwriteRange.end.character += nullNode.range[2] - offset; // extend range to the end of the null element
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not think this is going to be enough to insert a valid yaml. The overwriteRange.start.character should be adjusted so that there is no extra space between - and the inserted value.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, I'll have a look

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean this one?

Screen.Recording.2022-04-08.at.11.22.09.mov

hard to say, it looks ugly (extra indent), but the yaml is valid I think

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, in my tests when I inject a single item editor marks it as invalid.

@msivasubramaniaan msivasubramaniaan merged commit 9cfb0c7 into redhat-developer:main Apr 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants