Conclusion is that getDocumentContents is returning junk, doing the idempotent
test manually on vscode works as expected, but ends up with junk at the end of
the file in the test.
2020-03-12 21:11:05.79062259 [ThreadId 38] - Formatter.doFormatting: contents=
"{-# LANGUAGE NoImplicitPrelude #-}
module Format where
foo :: Int -> Int
foo 3 = 2
foo x = x
bar :: String -> IO String
bar s = do
x <- return \"hello\"
return \"asdf\"
"
2020-03-12 21:11:07.896114974 [ThreadId 7] - <--2--{"result":[{"range":{"start":{"line":0,"character":0},"end":{"line":9,"character":0}},"newText":
"{-# LANGUAGE NoImplicitPrelude #-}
module Format where
foo :: Int -> Int
foo 3 = 2
foo x = x
bar :: String -> IO String
bar s = do
x <- return \"hello\"
return \"asdf\"
"}],"jsonrpc":"2.0","id":1}
2020-03-12 21:11:07.897123428 [ThreadId 5] - ---> {"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"version":0,"uri":"file:///home/alanz/mysrc/github/alanz/haskell-language-server/test/testdata/Format.hs"},"contentChanges":[{"text":
"{-# LANGUAGE NoImplicitPrelude #-}
module Format where
foo :: Int -> Int
foo 3 = 2
foo x = x
bar :: String -> IO String
bar s = do
x <- return \"hello\"
return \"asdf\"
","range":{"start":{"line":0,"character":0},"end":{"line":9,"character":0}}}]}}
-------------------------------------------------------
2020-03-12 21:11:07.899375044 [ThreadId 213] - Formatter.doFormatting: contents="{-# LANGUAGE NoImplicitPrelude #-}
module Format where
foo :: Int -> Int
foo 3 = 2
foo x = x
bar :: String -> IO String
bar s = do
x <- return \"hello\"
return \"asdf\"
"
2020-03-12 21:11:07.902320214 [ThreadId 7] - <--2--{"result":[{"range":{"start":{"line":0,"character":0},"end":{"line":9,"character":0}},"newText":"{-# LANGUAGE NoImplicitPrelude #-}
module Format where
foo :: Int -> Int
foo 3 = 2
foo x = x
bar :: String -> IO String
bar s = do
x <- return \"hello\"
return \"asdf\"
"}],"jsonrpc":"2.0","id":2}
2020-03-12 21:11:07.902812215 [ThreadId 5] - ---> {"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"version":0,"uri":"file:///home/alanz/mysrc/github/alanz/haskell-language-server/test/testdata/Format.hs"},"contentChanges":[{"text":
"{-# LANGUAGE NoImplicitPrelude #-}
module Format where
foo :: Int -> Int
foo 3 = 2
foo x = x
bar :: String -> IO String
bar s = do
x <- return \"hello\"
return \"asdf\"
","range":{"start":{"line":0,"character":0},"end":{"line":9,"character":0}}}]}}
--------------------------------
hieCommand: haskell-language-server --lsp -d -l test-logs/hie-stack-8.6.5.yaml.log
HIE cache is warmed up
Format
formatting provider
formatting is idempotent FAILED [1]
Failures:
test/functional/FormatSpec.hs:64:42:
1) Format, formatting provider, formatting is idempotent
expected: "{-# LANGUAGE NoImplicitPrelude #-}\n\nmodule Format where\n\nfoo :: Int -> Int\nfoo 3 = 2\nfoo x = x\n\nbar :: String -> IO String\nbar s = do\n x <- return \"hello\"\n return \"asdf\"\n"
but got: "{-# LANGUAGE NoImplicitPrelude #-}\n\nmodule Format where\n\nfoo :: Int -> Int\nfoo 3 = 2\nfoo x = x\n\nbar :: String -> IO String\nbar s = do\n x <- return \"hello\"\n return \"asdf\"\nbar s = do\n x <- return \"hello\"\n return \"asdf\"\n"
To rerun use: --match "/Format/formatting provider/formatting is idempotent/"
Randomized with seed 1814425400
We only have an Ormolu formatter at present, want to make sure the circle stuff
actually works too.
Need to plumb the config values through to the actual formatter.