From 2e75030de6600e4050fa800f1468459e308d568f Mon Sep 17 00:00:00 2001 From: Ting-Gian LUA Date: Fri, 11 Dec 2020 18:10:31 +0800 Subject: [PATCH] Fix `swapUri` in Files.hs --- cabal.project | 11 +++++++++++ src/Language/LSP/Test/Files.hs | 11 +++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/cabal.project b/cabal.project index 140bc95..add6b65 100644 --- a/cabal.project +++ b/cabal.project @@ -3,3 +3,14 @@ packages: . flags: +DummyServer test-show-details: direct haddock-quickjump: True + +source-repository-package + type: git + location: https://github.com/banacorn/lsp.git + tag: 0556d22fc66f24bb526f671666183a86b485837e + subdir: lsp-types + +source-repository-package + type: git + location: https://github.com/banacorn/lsp.git + tag: 0556d22fc66f24bb526f671666183a86b485837e \ No newline at end of file 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 -- 2.30.2