From 95f43e0c9bd08feefadf1df4ec3cae2ff6c96384 Mon Sep 17 00:00:00 2001 From: Steve Dunham Date: Mon, 16 Feb 2026 10:01:44 -0800 Subject: [PATCH] Hover was repeatedly compiling modules in some cases --- src/Commands.newt | 3 +++ src/LSP.newt | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Commands.newt b/src/Commands.newt index 903d2e4..df4dfb3 100644 --- a/src/Commands.newt +++ b/src/Commands.newt @@ -26,7 +26,10 @@ decomposeName fn = -- 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 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 + -- 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 ] top <- getTop diff --git a/src/LSP.newt b/src/LSP.newt index f206628..a8f9526 100644 --- a/src/LSP.newt +++ b/src/LSP.newt @@ -96,13 +96,16 @@ hoverInfo uri line col = unsafePerformIO $ do if (st.baseDir /= base) then resetState base else pure MkUnit - Right (_, Just (msg, fc)) <- (getHoverInfo lspFileSource modns line col).runM st.topContext - | Right _ => do + -- We're proactively running check if there is no module information, make sure we save it + 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" pure $ jsonToJObject JsonNull | Left err => do putStrLn $ showError "" err pure $ jsonToJObject JsonNull + modifyIORef state $ [ topContext := top ] let location = JsonObj $ ("uri", JsonStr fc.file) :: ("range", fcToRange fc) :: Nil pure $ jsonToJObject $ JsonObj $ ("info", JsonStr msg) :: ("location", location) :: Nil