scalacenter / bloop

Bloop is a build server and CLI tool to compile, test and run Scala fast from any editor or build tool.
https://scalacenter.github.io/bloop/
Apache License 2.0
907 stars 201 forks source link

Use 0-based instead of 1-based line/column in BSP diagnostic #691

Closed olafurpg closed 5 years ago

olafurpg commented 6 years ago

Given the source file

package a

object A {
  val x: Int = ""
}

has a compilation error that is reported by bloop using 1-based line/column ranges instead of 0-based line/column ranges as the LSP + BSP specifications require https://microsoft.github.io/language-server-protocol/specification#text-documents

A position inside a document (see Position definition below) is expressed as a zero-based line and character offset.

screen shot 2018-10-23 at 12 48 58

The notification from bloop

- obtained
+ expected
{
    "uri": "file:/Users/ollie/dev/metals/test-workspace/src/main/scala/example/User.scala",
    "diagnostics": [
      {
        "range": {
          "start": {
-            "line": 4,
+            "line": 3,
            "character": 15
          },
          "end": {
-            "line": 4,
+            "line": 3,
            "character": 17
          }
        },
        "severity": 1,
        "message": "type mismatch;\n found   : String(\"\")\n required: Int"
      }
    ]
  }
olafurpg commented 6 years ago

The character numbers are correct, only the line numbers are 1-based