Hover was repeatedly compiling modules in some cases
This commit is contained in:
@@ -26,7 +26,10 @@ decomposeName fn =
|
|||||||
-- Later we will either get good FC for entries or scan them all and build a cache.
|
-- Later we will either get good FC for entries or scan them all and build a cache.
|
||||||
getHoverInfo : FileSource → String → Int → Int → M (Maybe (String × FC))
|
getHoverInfo : FileSource → String → Int → Int → M (Maybe (String × FC))
|
||||||
getHoverInfo repo modns row col = do
|
getHoverInfo repo modns row col = do
|
||||||
|
-- REVIEW consider not running processModule and returning empty if it hasn't been processed yet
|
||||||
|
-- For Elab.newt, there would be a 1.5s delay...
|
||||||
mod <- processModule emptyFC repo Nil modns
|
mod <- processModule emptyFC repo Nil modns
|
||||||
|
|
||||||
-- not necessarily loaded into top... (Maybe push this down into that branch of processModule)
|
-- not necessarily loaded into top... (Maybe push this down into that branch of processModule)
|
||||||
modifyTop [ defs := mod.modDefs; metaCtx := mod.modMetaCtx; ops := mod.ctxOps; imported := mod.modDeps ]
|
modifyTop [ defs := mod.modDefs; metaCtx := mod.modMetaCtx; ops := mod.ctxOps; imported := mod.modDeps ]
|
||||||
top <- getTop
|
top <- getTop
|
||||||
|
|||||||
@@ -96,13 +96,16 @@ hoverInfo uri line col = unsafePerformIO $ do
|
|||||||
if (st.baseDir /= base)
|
if (st.baseDir /= base)
|
||||||
then resetState base
|
then resetState base
|
||||||
else pure MkUnit
|
else pure MkUnit
|
||||||
Right (_, Just (msg, fc)) <- (getHoverInfo lspFileSource modns line col).runM st.topContext
|
-- We're proactively running check if there is no module information, make sure we save it
|
||||||
| Right _ => do
|
Right (top, Just (msg, fc)) <- (getHoverInfo lspFileSource modns line col).runM st.topContext
|
||||||
|
| Right (top, _) => do
|
||||||
|
modifyIORef state $ [ topContext := top ]
|
||||||
putStrLn $ "Nothing to see here"
|
putStrLn $ "Nothing to see here"
|
||||||
pure $ jsonToJObject JsonNull
|
pure $ jsonToJObject JsonNull
|
||||||
| Left err => do
|
| Left err => do
|
||||||
putStrLn $ showError "" err
|
putStrLn $ showError "" err
|
||||||
pure $ jsonToJObject JsonNull
|
pure $ jsonToJObject JsonNull
|
||||||
|
modifyIORef state $ [ topContext := top ]
|
||||||
let location = JsonObj $ ("uri", JsonStr fc.file) :: ("range", fcToRange fc) :: Nil
|
let location = JsonObj $ ("uri", JsonStr fc.file) :: ("range", fcToRange fc) :: Nil
|
||||||
pure $ jsonToJObject $ JsonObj $ ("info", JsonStr msg) :: ("location", location) :: Nil
|
pure $ jsonToJObject $ JsonObj $ ("info", JsonStr msg) :: ("location", location) :: Nil
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user