Skip to content

Commit

Permalink
use longer of ranges
Browse files Browse the repository at this point in the history
  • Loading branch information
roryc89 committed Nov 25, 2024
1 parent f624114 commit 29b54d2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Language/PureScript/Lsp/Handlers/Format.hs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ formatHandler = Server.requestHandler Message.SMethod_TextDocumentFormatting $ \
lspReadFileText $ Types.toNormalizedUri uri
Right imports -> pure $ printImports imports
formatted <- liftIO $ readProcess "purs-tidy" ["format"] (toS contents)
let lines' = toEnum $ length $ S.lines formatted
let lines' = toEnum $ max (length $ S.lines formatted) (length $ lines contents)
res $ Right $ Types.InL [Types.TextEdit (Types.Range (Types.Position 0 0) (Types.Position (lines' + 1) 0)) (toS formatted)]
_ -> res $ Left $ Message.TResponseError (Types.InR Types.ErrorCodes_InvalidParams) "No formatter set" Nothing
5 changes: 5 additions & 0 deletions src/Language/PureScript/Make/Actions.hs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ data MakeActions m = MakeActions
-- | Read the externs file for a module as a string and also return the actual
-- path for the file.
readExterns :: ModuleName -> m (FilePath, Maybe ExternsFile),
-- | Run actions using the final CheckState
-- checkState :: CheckState -> m (),
-- | Run the code generator for the module and write any required output files.
codegen :: Environment -> CheckState -> Module -> CF.Module CF.Ann -> Docs.Module -> ExternsFile -> SupplyT m (),
-- | Check ffi and print it in the output directory.
Expand Down Expand Up @@ -247,6 +249,9 @@ buildMakeActions outputDir filePathMap foreigns usePrefix =
codegenTargets <- asks optionsCodegenTargets
when (S.member Docs codegenTargets) $ for_ Docs.Prim.primModules $ \docsMod@Docs.Module {..} ->
writeJSONFile (outputFilename modName "docs.json") docsMod

-- checkState :: CheckState -> Make ()
-- checkState _ = return ()

codegen :: Environment -> CheckState -> Module -> CF.Module CF.Ann -> Docs.Module -> ExternsFile -> SupplyT Make ()
codegen _prevEnv _endEnv _m m docs exts = do
Expand Down

0 comments on commit 29b54d2

Please sign in to comment.