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

#989 Correct error line and column number #999

Merged
merged 1 commit into from
Nov 26, 2020
Merged

Conversation

joan38
Copy link
Collaborator

@joan38 joan38 commented Nov 10, 2020

No description provided.

pos.startLine.orElse(pos.line).getOrElse[Int](0),
pos.startOffset.orElse(pos.offset).getOrElse[Int](0)
pos.startLine.orElse(line).getOrElse[Int](0),
pos.startOffset.orElse(pos.pointer).getOrElse[Int](0)
Copy link
Collaborator Author

@joan38 joan38 Nov 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure it might be spacePointer here.
Also not sure if it starts from 1 or 0. I need to do some testing.

@ckipp01
Copy link
Contributor

ckipp01 commented Nov 24, 2020

Thanks for taking a look at this @joan38! Just tested it out, and much better!

Screenshot 2020-11-24 at 18 02 37

One other thing that I do notice though is that the diagnostic from Mill is as follows:

"diagnostics": [
    {
      "range": {
        "start": {
          "line": 8,
          "character": 15
        },
        "end": {
          "line": 8,
          "character": 15
        }
      },
      "severity": 1,
      "source": "compiler from mill",
      "message": "type mismatch;\n found   : String(\"hi\")\n required: Int"
    }
  ],

Whereas both with sbt and with Bloop it's:

"diagnostics": [
    {
      "range": {
        "start": {
          "line": 8,
          "character": 15
        },
        "end": {
          "line": 8,
          "character": 19
        }
      },
      "severity": 1,
      "source": "sbt",
      "message": "type mismatch;\n found   : String(\"hi\")\n required: Int"
    }
  ]

It still seems to work fine (I think there is some magic on the LSP client side) to maybe highlight the full symbol, but it'd be better to correctly capture the entire range and not return 15 for both start character and end character.

If it helps at all, here is the code sbt uses to get the range from the Problem.

https://github.com/sbt/sbt/blob/13b09bcd8fa0fde86aa4f4f8d7089fcb18e345c6/main/src/main/scala/sbt/internal/server/BuildServerReporter.scala#L133-L159

Copy link
Member

@lefou lefou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@lefou
Copy link
Member

lefou commented Nov 26, 2020

Merging this as it makes BSP error reporting significantly better. I'll open another issue for the open issue with the range end position.

@lefou lefou merged commit 71df0b1 into com-lihaoyi:master Nov 26, 2020
@lefou lefou added this to the after 0.9.3 milestone Nov 26, 2020
@lefou
Copy link
Member

lefou commented Nov 26, 2020

Thanks you @joan38 for the fix and @ckipp01 for the feedback!

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

Successfully merging this pull request may close these issues.

3 participants