ndmitchell / ghcid

Very low feature GHCi based IDE
Other
1.13k stars 114 forks source link

Infer ranges #373

Open chrismwendt opened 1 year ago

chrismwendt commented 1 year ago

Some GHC error messages have range info:

foo/Bar.hs:23:4-6: error: ...

And some don't, but they have annotations:

foo/Bar.hs:23:4: error:
...
   |
57 |         run source srv
   |             ^^^^^^

This PR parses the ^^^ annotations to infer range info so that the red squiggles show up on the whole range in VS Code, not just the first character.

In the process, I had to do some housekeeping: update TypeScript, mocha, migrate to @vscode/test-electron, etc.

cc @ndmitchell

chrismwendt commented 1 year ago

@ndmitchell It looks like the copyright year is out of date in CI:

https://github.com/ndmitchell/ghcid/actions/runs/4345680401/jobs/7590729342?pr=373#step:7:105

ndmitchell commented 1 year ago

Thanks for the patch. Should GHC HQ be adding the range if they clearly know it? It seems a bit weird to parse it out of the string. Have you reported this upstream?

I actually don't use the IDE extension anymore. So if you want to take over maintainership of this extension, you'd be most welcome to do so.

ndmitchell commented 1 year ago

Also, I wonder if this range inference should be in the Haskell side, if we do want to have it?

chrismwendt commented 1 year ago

Including the range info would be convenient for parsing, but on the other hand redundant with the annotation. I haven't reported this upstream since parsing makes it work on existing GHC versions.

I've been using HLS more recently and I don't use the ghcid IDE features much anymore either, so I don't think I'd be a responsive maintainer.

Also, I wonder if this range inference should be in the Haskell side, if we do want to have it?

Do you mean ghcid would read the GHC output, parse it, infer ranges, append the range info to errors, then print the augmented errors? I suppose the other plugins (nvim, emacs) would benefit from the info, too.