@@ -85,17 +85,16 @@ def addRef (i : RefInfo) (ref : Reference) : RefInfo :=
8585def toLspRefInfo (i : RefInfo) : BaseIO Lsp.RefInfo := do
8686 let refToRefInfoLocation (ref : Reference) : BaseIO RefInfo.Location := do
8787 let parentDeclName? := ref.ci.parentDecl?
88- let .ok parentDeclRanges? ← EIO.toBaseIO <| ref.ci.runCoreM do
89- let some parentDeclName := parentDeclName?
90- | return none
91- -- Use `local` as it avoids unnecessary blocking, which is especially important when called
92- -- from the snapshot reporter. Specifically, if `ref` is from a tactic of an async theorem,
93- -- `parentDeclName` will not be available in the current environment and we would block only
94- -- to return `none` in the end anyway. At the end of elaboration, we rerun this function on
95- -- the full info tree with the main environment, so the access will succeed immediately.
96- return declRangeExt.find? (asyncMode := .local) (← getEnv) parentDeclName
97- -- we only use `CoreM` to get access to a `MonadEnv`, but these are currently all `IO`
98- | unreachable!
88+ let parentDeclRanges? : Option DeclarationRanges := do
89+ -- Use final command env that has decl ranges for current declaration as well
90+ let cmdEnv ← ref.ci.cmdEnv?
91+ let parentDeclName ← parentDeclName?
92+ -- Use `local` as it avoids unnecessary blocking, which is especially important when called
93+ -- from the snapshot reporter. Specifically, if `ref` is from a tactic of an async theorem,
94+ -- `parentDeclName` will not be available in the current environment and we would block only
95+ -- to return `none` in the end anyway. At the end of elaboration, we rerun this function on
96+ -- the full info tree with the main environment, so the access will succeed immediately.
97+ declRangeExt.find? (asyncMode := .local) cmdEnv parentDeclName
9998 return {
10099 range := ref.range
101100 parentDecl? := do
0 commit comments