Skip to content
This repository has been archived by the owner on Oct 7, 2020. It is now read-only.

Commit

Permalink
Try to fix makeRefactorResult again
Browse files Browse the repository at this point in the history
  • Loading branch information
fendor committed Oct 3, 2019
1 parent dd9cbdd commit 15037a4
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions src/Haskell/Ide/Engine/Plugin/HaRe.hs
Expand Up @@ -18,6 +18,7 @@ import Data.Foldable
import Data.Monoid
#endif
import qualified Data.Text as T
import qualified Data.Text.IO as T
import Exception
import GHC.Generics (Generic)
import Haskell.Ide.Engine.ArtifactMap
Expand Down Expand Up @@ -213,16 +214,21 @@ makeRefactorResult changedFiles = do
uri <- canonicalizeUri $ filePathToUri fp
mvf <- getVirtualFile uri

case mvf of
Nothing ->
-- if there is no virtual file, dont try to persist it!
return $ IdeResultFail
(IdeError PluginError
(T.pack "makeRefactorResult: no access to the persisted file.")
Null
)
Just vf -> do
let origText = Rope.toText $ _text vf
origTextResult <- case mvf of
Nothing -> do
let resultFail = return $ IdeResultFail
(IdeError PluginError
(T.pack "makeRefactorResult: no access to the persisted file.")
Null
)
withMappedFile fp resultFail (fmap IdeResultOk . liftIO . T.readFile)
Just vf -> return $ IdeResultOk $ Rope.toText $ _text vf

case origTextResult of
IdeResultFail err -> do
logm "makeRefactorResult:could not retrieve original text"
return $ IdeResultFail err
IdeResultOk origText -> do
-- TODO: remove this logging once we are sure we have a working solution
logm $ "makeRefactorResult:groupedDiff = " ++ show (getGroupedDiff (lines $ T.unpack origText) (lines $ T.unpack newText))
logm $ "makeRefactorResult:diffops = " ++ show (diffToLineRanges $ getGroupedDiff (lines $ T.unpack origText) (lines $ T.unpack newText))
Expand Down

0 comments on commit 15037a4

Please sign in to comment.