You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor: remove unused parser state in example's environment extension
Only `Command.State` is needed to thread several example blocks.
Note that before we used the parsing state resulting from the last
code block, so we did resume from an offset that could be potentially
much before the current code block.
This worked as the string in that case was empty (produced by
`parserInputString`), but would have failed once we have reuse of the
input source string.
if header.raw[1].isNone then-- if the "prelude" option was not set, use the current env
448
448
let commandState := configureCommandState (← getEnv) {}
449
449
let commandState := { commandState with scopes := [{ header := "", opts := pp.tagAppFns.set {} true }] }
450
-
modifyEnv <| fun env => exampleContextExt.modifyState env fun s => {s with contexts := s.contexts.insert config.exampleContext.getId (.inline commandState state)}
450
+
modifyEnv <| fun env => exampleContextExt.modifyState env fun s => {s with contexts := s.contexts.insert config.exampleContext.getId (.inline commandState)}
451
451
else
452
452
if header.raw[2].getArgs.isEmpty then
453
453
let (env, msgs) ← processHeader header opts msgs context 0
let commandState := { commandState with scopes := [{ header := "", opts := pp.tagAppFns.set {} true }] }
460
-
modifyEnv <| fun env => exampleContextExt.modifyState env fun s => {s with contexts := s.contexts.insert config.exampleContext.getId (.inline commandState state)}
460
+
modifyEnv <| fun env => exampleContextExt.modifyState env fun s => {s with contexts := s.contexts.insert config.exampleContext.getId (.inline commandState)}
461
461
if config.show then
462
462
``(Block.code $(quote str.getString)) -- TODO highlighting hack
463
463
else
@@ -471,16 +471,17 @@ open SubVerso.Highlighting Highlighted in
471
471
deflean : CodeBlockExpanderOf LeanBlockConfig
472
472
| config, str => withTraceNode `Elab.Verso.block.lean (fun _ => pure m!"lean block") <| withoutAsync do
473
473
let x := config.exampleContext
474
-
let(commandState, state) ← match exampleContextExt.getState (← getEnv) |>.contexts.find? x.getId with
475
-
| some (.inline commandState state) => pure (commandState, state)
474
+
let commandState ← match exampleContextExt.getState (← getEnv) |>.contexts.find? x.getId with
475
+
| some (.inline commandState) => pure (commandState)
476
476
| some (.subproject ..) => throwErrorAt x "Expected an example context for inline Lean, but found a subproject"
477
477
| some (.module ..) => throwErrorAt x "Expected an example context for inline Lean, but found a module"
478
478
| none => throwErrorAt x "Can't find example context"
479
479
let (context, startPos) ← strLitInputContext str.raw (← getFileName)
480
+
let state := { pos := startPos }
480
481
-- Process with empty messages to avoid duplicate output
481
482
let s ←
482
483
withTraceNode `Elab.Verso.block.lean (fun _ => pure m!"Elaborating commands") <|
0 commit comments