X-Git-Url: https://git.lukelau.me/?p=lsp-test.git;a=blobdiff_plain;f=src%2FLanguage%2FLSP%2FTest%2FFiles.hs;h=231f3e6598aa2817e4767fb9c9f938d71307c924;hp=8fc78cf608149fa71edce726e7e4d18deae8db73;hb=2e75030de6600e4050fa800f1468459e308d568f;hpb=f89cfd8c1b3fe2b9e0805b564216ab3a5eda1b82 diff --git a/src/Language/LSP/Test/Files.hs b/src/Language/LSP/Test/Files.hs index 8fc78cf..231f3e6 100644 --- a/src/Language/LSP/Test/Files.hs +++ b/src/Language/LSP/Test/Files.hs @@ -11,7 +11,7 @@ module Language.LSP.Test.Files where import Language.LSP.Types -import Language.LSP.Types.Lens +import Language.LSP.Types.Lens hiding (id) import Control.Lens import qualified Data.HashMap.Strict as HM import qualified Data.Text as T @@ -75,7 +75,14 @@ mapUris f event = swapWorkspaceEdit :: WorkspaceEdit -> WorkspaceEdit swapWorkspaceEdit e = - let newDocChanges = fmap (fmap (swapUri textDocument)) $ e ^. documentChanges + let swapDocumentChangeUri :: DocumentChange -> DocumentChange + swapDocumentChangeUri (InL textDocEdit) = InL $ swapUri textDocument textDocEdit + swapDocumentChangeUri (InR (InL createFile)) = InR $ InL $ swapUri id createFile + -- for RenameFile, we swap `newUri` + swapDocumentChangeUri (InR (InR (InL renameFile))) = InR $ InR $ InL $ newUri .~ f (renameFile ^. newUri) $ renameFile + swapDocumentChangeUri (InR (InR (InR deleteFile))) = InR $ InR $ InR $ swapUri id deleteFile + + newDocChanges = fmap (fmap swapDocumentChangeUri) $ e ^. documentChanges newChanges = fmap (swapKeys f) $ e ^. changes in WorkspaceEdit newChanges newDocChanges