|
2 | 2 | {-# LANGUAGE GADTs #-}
|
3 | 3 | {-# LANGUAGE DuplicateRecordFields #-}
|
4 | 4 | {-# LANGUAGE OverloadedStrings #-}
|
| 5 | +{-# LANGUAGE ScopedTypeVariables #-} |
5 | 6 | {-# LANGUAGE DeriveGeneric #-}
|
6 | 7 | {-# LANGUAGE DeriveAnyClass #-}
|
7 | 8 |
|
@@ -132,7 +133,37 @@ main = hspec $ around withDummyServer $ do
|
132 | 133 | in runSessionWithHandles hin hout def fullCaps "." sesh
|
133 | 134 | `shouldThrow` selector
|
134 | 135 |
|
135 |
| - describe "text document VFS" $ |
| 136 | + describe "text document VFS" $ do |
| 137 | + it "sends back didChange notifications (documentChanges)" $ \(hin, hout) -> |
| 138 | + runSessionWithHandles hin hout def fullCaps "." $ do |
| 139 | + doc <- openDoc "test/data/refactor/Main.hs" "haskell" |
| 140 | + VersionedTextDocumentIdentifier _ beforeVersion <- getVersionedDoc doc |
| 141 | + |
| 142 | + let args = toJSON (VersionedTextDocumentIdentifier (doc ^. uri) beforeVersion) |
| 143 | + reqParams = ExecuteCommandParams Nothing "doAVersionedEdit" (Just (List [args])) |
| 144 | + |
| 145 | + request_ SWorkspaceExecuteCommand reqParams |
| 146 | + |
| 147 | + editReq <- message SWorkspaceApplyEdit |
| 148 | + liftIO $ do |
| 149 | + let Just (List [InL(TextDocumentEdit vdoc (List [InL edit_]))]) = |
| 150 | + editReq ^. params . edit . documentChanges |
| 151 | + vdoc `shouldBe` VersionedTextDocumentIdentifier (doc ^. uri) beforeVersion |
| 152 | + edit_ `shouldBe` TextEdit (Range (Position 0 0) (Position 0 5)) "howdy" |
| 153 | + |
| 154 | + change <- customNotification "custom/textDocument/didChange" |
| 155 | + let NotMess (NotificationMessage _ _ (c::Value)) = change |
| 156 | + Success (DidChangeTextDocumentParams reportedVDoc _edit) = fromJSON c |
| 157 | + VersionedTextDocumentIdentifier _ reportedVersion = reportedVDoc |
| 158 | + |
| 159 | + contents <- documentContents doc |
| 160 | + |
| 161 | + liftIO $ contents `shouldBe` "howdy:: IO Int\nmain = return (42)\n" |
| 162 | + VersionedTextDocumentIdentifier _ afterVersion <- getVersionedDoc doc |
| 163 | + liftIO $ afterVersion `shouldNotBe` beforeVersion |
| 164 | + |
| 165 | + liftIO $ reportedVersion `shouldNotBe` beforeVersion |
| 166 | + |
136 | 167 | it "sends back didChange notifications" $ \(hin, hout) ->
|
137 | 168 | runSessionWithHandles hin hout def fullCaps "." $ do
|
138 | 169 | doc <- openDoc "test/data/refactor/Main.hs" "haskell"
|
|
0 commit comments