@@ -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