cmake-language-server icon indicating copy to clipboard operation
cmake-language-server copied to clipboard

insertTextFormat (and other values) provided as `null`

Open puremourning opened this issue 4 years ago • 1 comments

Values in LSP may only be null where explicitly stated in the spec, i.e. with their type including | null.

insertTextFormat has the specification:

	/**
	 * The format of the insert text. The format applies to both the
	 * `insertText` property and the `newText` property of a provided
	 * `textEdit`. If omitted defaults to `InsertTextFormat.PlainText`.
	 */
	insertTextFormat?: InsertTextFormat;

And therefore may not be null (but may be omitted, hence the ?).

But cmake-language-server returns null for insertTextFormat. this is not valid, and breaks conforming clients.

Example:

2021-04-20 17:32:21,948 - DEBUG - RX: Received message: b'{"id": 3, "jsonrpc": "2.0", "result": {"isIncomplete": false, "items": [{"label": "set", "kind": 3, "detail": null, "documentation": "```cmake\\nset()\\n```", "deprecated": false, "preselect": false, "sortText": null, "filterText": null, "insertText": "set", "insertTextFormat": null, "textEdit": null, "additionalTextEdits": null, "commitCharacters": null, "command": null, "data": null}, {"label": "set_directory_properties", "kind": 3, "detail": null, "documentation": "```cmake\\nset_directory_properties(PROPERTIES prop1 value1 [prop2 value2] ...)\\n```", "deprecated": false, "preselect": false, "sortText": null, "filterText": null, "insertText": "set_directory_properties", "insertTextFormat": null, "textEdit": null, "additionalTextEdits": null, "commitCharacters": null, "command": null, "data": null}, {"label": "set_property", "kind": 3, "detail": null, "documentation": "```cmake\\nset_property(<GLOBAL                      |\\n              DIRECTORY [<dir>]           |\\n              TARGET    [<target1> ...]   |\\n              SOURCE    [<src1> ...]\\n                        [DIRECTORY <dirs> ...] |\\n                        [TARGET_DIRECTORY <targets> ...]\\n              INSTALL   [<file1> ...]     |\\n              TEST      [<test1> ...]     |\\n              CACHE     [<entry1> ...]    >\\n             [APPEND] [APPEND_STRING]\\n             PROPERTY <name> [<value1> ...])\\n```", "deprecated": false, "preselect": false, "sortText": null, "filterText": null, "insertText": "set_property", "insertTextFormat": null, "textEdit": null, "additionalTextEdits": null, "commitCharacters": null, "command": null, "data": null}, {"label": "set_source_files_properties", "kind": 3, "detail": null, "documentation": "```cmake\\nset_source_files_properties(<files> ...\\n                            [DIRECTORY <dirs> ...]\\n                            [TARGET_DIRECTORY <targets> ...]\\n                            PROPERTIES <prop1> <value1>\\n                            [<prop2> <value2>] ...)\\n```", "deprecated": false, "preselect": false, "sortText": null, "filterText": null, "insertText": "set_source_files_properties", "insertTextFormat": null, "textEdit": null, "additionalTextEdits": null, "commitCharacters": null, "command": null, "data": null}, {"label": "set_target_properties", "kind": 3, "detail": null, "documentation": "```cmake\\nset_target_properties(target1 target2 ...\\n                      PROPERTIES prop1 value1\\n                      prop2 value2 ...)\\n```", "deprecated": false, "preselect": false, "sortText": null, "filterText": null, "insertText": "set_target_properties", "insertTextFormat": null, "textEdit": null, "additionalTextEdits": null, "commitCharacters": null, "command": null, "data": null}, {"label": "set_tests_properties", "kind": 3, "detail": null, "documentation": "```cmake\\nset_tests_properties(test1 [test2...] PROPERTIES prop1 value1 prop2 value2)\\n```", "deprecated": false, "preselect": false, "sortText": null, "filterText": null, "insertText": "set_tests_properties", "insertTextFormat": null, "textEdit": null, "additionalTextEdits": null, "commitCharacters": null, "command": null, "data": null}]}}'

I was led to believe that this was fixed in pygls under https://github.com/openlawlibrary/pygls/pull/139

puremourning avatar Apr 20 '21 16:04 puremourning

Thank you for reporting. If you tried the PyPI released version, would you please try the latest master? The master requires pygls 0.10, which includes openlawlibrary/pygls#139.

regen100 avatar Apr 20 '21 17:04 regen100