Skip to content

Commit d17dce9

Browse files
authored
Use Empty instead of () as progress create response (#295)
* Use Empty instead of () as progress create response * Add null field to notifications before parsing also * fix compile
1 parent cc67943 commit d17dce9

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

lsp-test/src/Language/LSP/Test/Session.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ where
3838
import Control.Applicative
3939
import Control.Concurrent hiding (yield)
4040
import Control.Exception
41-
import Control.Lens hiding (List)
41+
import Control.Lens hiding (List, Empty)
4242
import Control.Monad
4343
import Control.Monad.IO.Class
4444
import Control.Monad.Except
@@ -304,7 +304,7 @@ updateStateC = awaitForever $ \msg -> do
304304
where
305305
respond :: (MonadIO m, HasReader SessionContext m) => FromServerMessage -> m ()
306306
respond (FromServerMess SWindowWorkDoneProgressCreate req) =
307-
sendMessage $ ResponseMessage "2.0" (Just $ req ^. LSP.id) (Right ())
307+
sendMessage $ ResponseMessage "2.0" (Just $ req ^. LSP.id) (Right Empty)
308308
respond (FromServerMess SWorkspaceApplyEdit r) = do
309309
sendMessage $ ResponseMessage "2.0" (Just $ r ^. LSP.id) (Right $ ApplyWorkspaceEditResponseBody True Nothing)
310310
respond _ = pure ()

lsp-types/src/Language/LSP/Types/Message.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ type family ResponseResult (m :: Method f Request) :: Type where
197197
-- Server
198198
-- Window
199199
ResponseResult WindowShowMessageRequest = Maybe MessageActionItem
200-
ResponseResult WindowWorkDoneProgressCreate = ()
200+
ResponseResult WindowWorkDoneProgressCreate = Empty
201201
-- Capability
202202
ResponseResult ClientRegisterCapability = Empty
203203
ResponseResult ClientUnregisterCapability = Empty
@@ -233,7 +233,7 @@ deriving instance Eq (MessageParams m) => Eq (NotificationMessage m)
233233
deriving instance Show (MessageParams m) => Show (NotificationMessage m)
234234

235235
instance (FromJSON (MessageParams m), FromJSON (SMethod m)) => FromJSON (NotificationMessage m) where
236-
parseJSON = genericParseJSON lspOptions
236+
parseJSON = genericParseJSON lspOptions . addNullField "params"
237237
instance (ToJSON (MessageParams m)) => ToJSON (NotificationMessage m) where
238238
toJSON = genericToJSON lspOptions
239239
toEncoding = genericToEncoding lspOptions

src/Language/LSP/Server/Core.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ withProgressBase indefinite title cancellable f = do
620620
-- An error ocurred when the client was setting it up
621621
-- No need to do anything then, as per the spec
622622
Left _err -> pure ()
623-
Right () -> pure ()
623+
Right Empty -> pure ()
624624

625625
-- Send the begin and done notifications via 'bracket_' so that they are always fired
626626
res <- withRunInIO $ \runInBase ->

0 commit comments

Comments
 (0)