AdaCore / ada_language_server

Server implementing the Microsoft Language Protocol for Ada and SPARK
GNU General Public License v3.0
230 stars 54 forks source link

rangeFormatting response is invalid #1074

Closed stephe-ada-guru closed 1 year ago

stephe-ada-guru commented 1 year ago

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.

joaopsazevedo commented 1 year ago

This issue is now fixed in the the edge branch. Thank you for reporting and for the reproducer.