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

null value fields in payload should be skipped #145

Closed
karthiknadig opened this issue Feb 4, 2021 · 3 comments
Closed

null value fields in payload should be skipped #145

karthiknadig opened this issue Feb 4, 2021 · 3 comments

Comments

@karthiknadig
Copy link
Contributor

karthiknadig commented Feb 4, 2021

I am not sure if the LSP spec specifies if you can use null for optional fields in response or notification. But this seems to cause issues with VS Code.

Here is an example, consider this response content from pygls:

[
    {
        "name": "SampleClass",
        "kind": 5,
        "range": {
            "start": {
                "line": 17,
                "character": 0
            },
            "end": {
                "line": 19,
                "character": 12
            }
        },
        "selectionRange": {
            "start": {
                "line": 17,
                "character": 6
            },
            "end": {
                "line": 17,
                "character": 17
            }
        },
        "detail": null,
        "children": [
            {
                "name": "__init__",
                "kind": 6,
                "range": {
                    "start": {
                        "line": 18,
                        "character": 4
                    },
                    "end": {
                        "line": 19,
                        "character": 12
                    }
                },
                "selectionRange": {
                    "start": {
                        "line": 18,
                        "character": 8
                    },
                    "end": {
                        "line": 18,
                        "character": 16
                    }
                },
                "detail": null,
                "children": [],
                "deprecated": false
            }
        ],
        "deprecated": false
    }
]

Notice the "detail": null, looks like VS Code does not like that. Outline does not show up in VS Code UI when "detail": null.

Removing that null fields seems fix the issue with Outline not showing. This is the same case with CodeActions as well where the optional fields get null and it does not show up in VS Code UI.

Typical CodeAction response:

```json
{
        "title": "Extract expression into function 'func_njmjvxyh'",
        "kind": "refactor.extract",
        "diagnostics": null,
        "edit": {
            "changes": null,
            "documentChanges": [
                {
                    "textDocument": {
                        "uri": "file:///c:/GIT/repro/lsptest/tests/test_math.py",
                        "version": null
                    },
                    "edits": [
                        {
                            "range": {
                                "start": {
                                    "line": 18,
                                    "character": 8
                                },
                                "end": {
                                    "line": 18,
                                    "character": 8
                                }
                            },
                            "newText": "func_njmjvxyh(self):\n        \r\n        return \n\n    def "
                        },
                        {
                            "range": {
                                "start": {
                                    "line": 19,
                                    "character": 12
                                },
                                "end": {
                                    "line": 19,
                                    "character": 14
                                }
                            },
                            "newText": " = self.func_njmjvxyh()\n"
                        }
                    ]
                }
            ]
        },
        "command": null
    }

Related: https://github.com/microsoft/vscode/issues/115793
Related: pappasam/jedi-language-server#60

@krassowski
Copy link

Already tracked in #124 I believe. The consensus appears to be that nulls are not allowed unless explicitly specified in the protocol.

@danixeee
Copy link
Contributor

danixeee commented Feb 5, 2021

@karthiknadig

As @krassowski said, we are aware of that and the bug should be fixed in #139. It will be merged and released soon, but there will be backwards-incompatible changes.

@danixeee
Copy link
Contributor

Solved in #139.

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

No branches or pull requests

3 participants