Skip to content
This repository has been archived by the owner on Oct 7, 2020. It is now read-only.

Only run diagnostics onSave #1164

Merged
merged 4 commits into from
Apr 9, 2019
Merged

Only run diagnostics onSave #1164

merged 4 commits into from
Apr 9, 2019

Conversation

lorenzo
Copy link
Collaborator

@lorenzo lorenzo commented Apr 6, 2019

This introduces a behaviour change in that hie will only run diagnostics on a file after it has been open and saved, unless the user hasn't manually configured the client to run diagnostics on chages.

I have found that running diagnostics as I type creates too much noise in my editor as more often than not I'm in a broken state. Additionally, this it makes HIE appear that it runs faster.

  • Added the diagnosticsOnChange client config value
  • Refactored the reactor a bit to not have hardcoded defaults smattered everywhere, which in some cases were inconsistent.

@lorenzo lorenzo requested review from alanz, lukel97 and fendor April 6, 2019 17:16
@lukel97
Copy link
Collaborator

lukel97 commented Apr 7, 2019

I’m confused as to how the tests are passing, since they aren’t sending any didSave notifications.

@lorenzo
Copy link
Collaborator Author

lorenzo commented Apr 7, 2019

@bubba only 2 tests where calling noDiagnostics after executing a text change. The other tests were only asserting that diagnostics were returned after a file was opened.

@lukel97
Copy link
Collaborator

lukel97 commented Apr 7, 2019

@lorenzo some of the tests do send applyedit requests though:

it "works" $ runSession hieCommand fullCaps "test/testdata/completion" $ do
doc <- openDoc "Completion.hs" "haskell"
_ <- skipManyTill loggingNotification (count 2 noDiagnostics)
let te = TextEdit (Range (Position 5 7) (Position 5 24)) "put"
_ <- applyEdit doc te
compls <- getCompletions doc (Position 5 9)
let item = head $ filter ((== "putStrLn") . (^. label)) compls
liftIO $ do
item ^. label `shouldBe` "putStrLn"
item ^. kind `shouldBe` Just CiFunction
item ^. detail `shouldBe` Just "String -> IO ()\nPrelude"
item ^. insertTextFormat `shouldBe` Just Snippet
item ^. insertText `shouldBe` Just "putStrLn ${1:String}"

Copy link
Collaborator

@lukel97 lukel97 left a comment

Choose a reason for hiding this comment

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

+1 on the addition of of the config option, but I'm not so sure on making onSave the default. I can imagine this would cause confusion for people upgrading when diagnostics are no longer being returned immediately. Are there any other language servers that only return on save by default? Most of the builtin VS code language servers (JS/python etc) seem to run diagnostics on change.
Hopefully with the upcoming changes the BIOS and the new .hie files, the latency with running and fetching diagnostics won't be so bad.

@lorenzo
Copy link
Collaborator Author

lorenzo commented Apr 7, 2019

Are there any other language servers that only return on save by default

All of the language servers I used for work do it on save: Golang, Python, Elm, PHP... The one I struggle with the most is the Haskell one because of all the constant noise I get while I'm in an obviously broken state as I move stuff around. I'm confident most people must be having the same type of problems as I do.

The problem is not the latency, which is also annoying, but the constant showing of errors as I type.

Edit: I just realised that I changed the python's lang server behaviour for the exact same problem. Way too much noise as I typed.

@lorenzo
Copy link
Collaborator Author

lorenzo commented Apr 7, 2019

some of the tests do send applyedit requests though:

Right, but the test is not doing any assertions on the diagnostics after changing the test. The only thing that I changed here is running diagnostics, the rest is kept unchanged.

@alanz
Copy link
Collaborator

alanz commented Apr 7, 2019

I agree that the default should be to preserve the current behaviour, rather than only generating diagnostics on save.

@lukel97
Copy link
Collaborator

lukel97 commented Apr 7, 2019

The problem is not the latency, which is also annoying, but the constant showing of errors as I type.

I do agree though that we should definitely support this workflow in some form. I can also imagine a wide variety of scenarios such as having really large modules which take a long time to typecheck where on save behaviour is probably preferred.

(Accidentally closed this, please ignore!)

@lukel97 lukel97 closed this Apr 7, 2019
@lukel97 lukel97 reopened this Apr 7, 2019
@lorenzo
Copy link
Collaborator Author

lorenzo commented Apr 8, 2019

Ok, seems there does not seem to be lots of support for making this the default, I'll make it a configuration option only and revert to the previous default.

mpickering and others added 4 commits April 8, 2019 21:19
previous calls had defaults scattered all over the place and they often
were contradictory.
@lorenzo lorenzo changed the title Only run diagnostics onSave, by default Only run diagnostics onSave Apr 8, 2019
@lorenzo
Copy link
Collaborator Author

lorenzo commented Apr 8, 2019

@bubba @alanz I set the default to True to preserve the old behaviour. This can be merged whenever you like

@alanz alanz merged commit fbb7574 into master Apr 9, 2019
@lorenzo lorenzo deleted the diagnostics-on-save branch April 9, 2019 20:06
@alanz alanz added this to the 2019-04 milestone May 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants