@@ -6,6 +6,7 @@ import Control.Lens ((^.))
6
6
import Control.Monad.IO.Class
7
7
import Data.Aeson
8
8
import qualified Data.ByteString.Lazy as BS
9
+ import qualified Data.Text as T
9
10
import qualified Data.Text.Encoding as T
10
11
import qualified Data.Text.IO as T
11
12
import Language.LSP.Test
@@ -47,8 +48,7 @@ providerTests = testGroup "formatting provider" [
47
48
testCase " respects none" $ runSessionWithConfig (formatConfig " none" ) hlsCommand fullCaps " test/testdata/format" $ do
48
49
doc <- openDoc " Format.hs" " haskell"
49
50
resp <- request STextDocumentFormatting $ DocumentFormattingParams Nothing doc (FormattingOptions 2 True Nothing Nothing Nothing )
50
- liftIO $ resp ^. LSP. result @?= Left (ResponseError InvalidRequest " No plugin enabled for STextDocumentFormatting, available:\n PluginId \" floskell\"\n PluginId \" fourmolu\"\n PluginId \" ormolu\"\n PluginId \" stylish-haskell\"\n PluginId \" brittany\"\n " Nothing )
51
-
51
+ liftIO $ foramattingNoneResultCorrect (resp ^. LSP. result) @? " Result incorrect"
52
52
, requiresOrmoluPlugin . requiresFloskellPlugin $ testCase " can change on the fly" $ runSession hlsCommand fullCaps " test/testdata/format" $ do
53
53
formattedOrmolu <- liftIO $ T. readFile " test/testdata/format/Format.ormolu.formatted.hs"
54
54
formattedFloskell <- liftIO $ T. readFile " test/testdata/format/Format.floskell.formatted.hs"
@@ -81,6 +81,10 @@ providerTests = testGroup "formatting provider" [
81
81
formatDoc doc (FormattingOptions 2 True Nothing Nothing Nothing )
82
82
documentContents doc >>= liftIO . (@?= formattedFloskell)
83
83
]
84
+ where
85
+ foramattingNoneResultCorrect (Left (ResponseError InvalidRequest text Nothing )) =
86
+ T. isPrefixOf " No plugin enabled for STextDocumentFormatting" text
87
+ foramattingNoneResultCorrect _ = False
84
88
85
89
formatLspConfig :: Value -> Value
86
90
formatLspConfig provider = object [ " haskell" .= object [" formattingProvider" .= (provider :: Value )] ]
0 commit comments