Description
In the following code snippet, applying the code action modifies the goal but the tactic state remains unchanged.
import Batteries.CodeAction
open Lean Elab Server Lsp RequestM
open Batteries.CodeAction
def rwAddCommQuickFix (tac : Syntax) : RequestM (Array LazyCodeAction) := do
let some range := tac.getRange? | return #[]
let doc ← readDoc
let eager : Lsp.CodeAction := {
title := "Replace with `rw [Nat.add_comm, Nat.one_add]`"
kind? := "quickfix"
edit? := some <| .ofTextEdit doc.versionedIdentifier {
range := doc.meta.text.utf8RangeToLspRange range
newText := "rw [Nat.add_comm, Nat.one_add]"
}
}
return #[{ eager }]
@[tactic_code_action]
def codeAct : TacticSeqCodeAction := fun _params _snap _ctx i stack _goals => do
if i == 0 then return #[]
let (seq, _) :: _ := stack | return #[]
rwAddCommQuickFix seq[2 * (i - 1)]
example (n : Nat) : n = n + 1 := by
rw [Nat.add_comm]
-- place cursor here
Context
Identified by @JovanGerb.
Steps to Reproduce
- Place cursor at the beginning of the line below the line
rw [Nat.add_comm].
- Apply code action.
- Tactic state remains unchanged.
- Move cursor left or right - tactic state is updated.
Expected behavior: Tactic state is refreshed.
Actual behavior: It is not refreshed.
Versions
Lean playground (also reproduces in VS Code)
Lean 4.31.0-rc2
Target: x86_64-unknown-linux-gnu
Impact
Add 👍 to issues you consider important. If others are impacted by this issue, please ask them to add 👍 to it.
Description
In the following code snippet, applying the code action modifies the goal but the tactic state remains unchanged.
Context
Identified by @JovanGerb.
Steps to Reproduce
rw [Nat.add_comm].Expected behavior: Tactic state is refreshed.
Actual behavior: It is not refreshed.
Versions
Lean playground (also reproduces in VS Code)
Lean 4.31.0-rc2
Target: x86_64-unknown-linux-gnu
Impact
Add 👍 to issues you consider important. If others are impacted by this issue, please ask them to add 👍 to it.