Skip to content

rangeFormatting response is invalid #1074

@stephe-ada-guru

Description

@stephe-ada-guru

This uses the same test.json as issue #1073 (attached)
test.json.txt

Once the assertion_error in #1073 is fixed, the response to the rangeFormatting request is (formatted for readability):
[(:range
(:start (:line 0 :character 28)
:end (:line 0 :character 27))
:newText "\n")
(:range
(:start (:line 1 :character 0)
:end (:line 1 :character 0))
:newText " ")
(:range
(:start (:line 3 :character 15)
:end (:line 4 :character 0))
:newText " ")
(:range
(:start (:line 4 :character 2)
:end (:line 4 :character 3))
:newText "\n")
(:range
(:start (:line 5 :character 0)
:end (:line 5 :character 0))
:newText " ")]

The first range appears to violate https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#range; it specifies a region that starts at 28 and ends at 27 (exclusive), which is not possible. It appears that the edit is trying to insert a newline without deleting any text; if so, the range should be 28 .. 28.

The other ranges are ok. However, the overall formatting is very odd; there is a blank line in the with clause, and continuation lines are indented by 8. Ah - it appears to be using 'tabSize' as the base indent; changing that changes the indent accordingly. I'll submit a separate issue on this.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions