Skip to content

Commit 6459b2e

Browse files
Make incrementality optional
1 parent 2fb7a2e commit 6459b2e

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

REPL/JSON.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ structure CommandOptions where
1919
Anything else is ignored.
2020
-/
2121
infotree : Option String
22+
incrementality : Option Bool := none -- whether to use incremental mode optimization
2223

2324
/-- Run Lean commands.
2425
If `env = none`, starts a new session (in which you can use `import`).

REPL/Main.lean

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -369,19 +369,20 @@ def runCommand (s : Command) : M IO (CommandResponse ⊕ Error) := do
369369
return .inr ⟨"Unknown environment."
370370
let initialCmdState? := cmdSnapshot?.map fun c => c.cmdState
371371

372-
-- Find the best incremental state to reuse based on prefix matching
373-
let bestIncrementalState? ← findBestIncrementalState s.cmd s.env
374-
375-
let (initialCmdState, incStates, messages, headerCache) ← try
376-
IO.processInput s.cmd initialCmdState? bestIncrementalState? (← get).headerCache
372+
let (initialCmdState, incStates, messages) ← try
373+
if s.incrementality.getD false then
374+
let bestIncrementalState? ← findBestIncrementalState s.cmd s.env
375+
let (initialCmdState, incStates, messages, headerCache) ← IO.processInput s.cmd initialCmdState? bestIncrementalState? (← get).headerCache
376+
-- Store the command text and incremental states for future reuse
377+
modify fun st => { st with headerCache := headerCache }
378+
recordCommandIncrementals s.cmd incStates s.env
379+
pure (initialCmdState, incStates, messages)
380+
else
381+
let (initialCmdState, incStates, messages, _) ← IO.processInput s.cmd initialCmdState? none {}
382+
pure (initialCmdState, incStates, messages)
377383
catch ex =>
378384
return .inr ⟨ex.toString⟩
379385

380-
modify fun st => { st with headerCache := headerCache }
381-
382-
-- Store the command text and incremental states for future reuse
383-
recordCommandIncrementals s.cmd incStates s.env
384-
385386
let cmdState := (incStates.getLast?.map (fun c => c.1.commandState)).getD initialCmdState
386387
let messages ← messages.mapM fun m => Message.of m
387388
let sorries ← sorriesCmd incStates initialCmdState.env none

0 commit comments

Comments
 (0)