fix: issue where code action was not running
This commit is contained in:
parent
c795e2b073
commit
297d06fc0c
5 changed files with 24 additions and 16 deletions
|
|
@ -245,7 +245,16 @@ def ofTextDocumentEdit (e : TextDocumentEdit) : WorkspaceEdit :=
|
|||
{ documentChanges := #[DocumentChange.edit e]}
|
||||
|
||||
def ofTextEdit (uri : DocumentUri) (te : TextEdit) : WorkspaceEdit :=
|
||||
{ changes := RBMap.empty.insert uri #[te]}
|
||||
/- [note], there is a bug in vscode where not including the version will cause an error,
|
||||
even though the version field is not used to validate the change.
|
||||
|
||||
References:
|
||||
- [a fix in the wild](https://github.com/stylelint/vscode-stylelint/pull/330/files).
|
||||
Note that the version field needs to be present, even if the value is `undefined`.
|
||||
- [angry comment](https://github.com/tsqllint/tsqllint-vscode-extension/blob/727026fce9f8c6a33d113373666d0776f8f6c23c/server/src/server.ts#L70)
|
||||
-/
|
||||
let doc := {uri, version? := some 0}
|
||||
ofTextDocumentEdit { textDocument := doc, edits := #[te]}
|
||||
|
||||
end WorkspaceEdit
|
||||
|
||||
|
|
|
|||
|
|
@ -36,9 +36,6 @@ Rather than run the heavy ML computation in the CodeActionProvider, you could su
|
|||
def CodeActionProvider := CodeActionParams → RequestM (RequestTask (Array CodeAction))
|
||||
deriving instance Inhabited for CodeActionProvider
|
||||
|
||||
def CodeActionResolver := CodeAction → RequestM (RequestTask CodeAction)
|
||||
deriving instance Inhabited for CodeActionResolver
|
||||
|
||||
builtin_initialize codeActionProviderExt : SimplePersistentEnvExtension Name NameSet ← registerSimplePersistentEnvExtension {
|
||||
name := `codeActionProviderExt,
|
||||
addImportedFn := fun nss => nss.foldl (fun acc ns => ns.foldl NameSet.insert acc) ∅
|
||||
|
|
|
|||
|
|
@ -690,7 +690,10 @@ def mkLeanServerCapabilities : ServerCapabilities := {
|
|||
full := true
|
||||
range := true
|
||||
}
|
||||
codeActionProvider? := some { }
|
||||
codeActionProvider? := some {
|
||||
resolveProvider? := true,
|
||||
codeActionKinds? := some #["quickfix", "refactor"]
|
||||
}
|
||||
}
|
||||
|
||||
def initAndRunWatchdogAux : ServerM Unit := do
|
||||
|
|
|
|||
|
|
@ -11,8 +11,7 @@ def helloProvider : CodeActionProvider := fun (params : CodeActionParams) => do
|
|||
edit? := WorkspaceEdit.ofTextEdit uri {
|
||||
range := params.range,
|
||||
newText := "hello!!!",
|
||||
},
|
||||
data := {uri}
|
||||
}
|
||||
}]
|
||||
|
||||
theorem asdf : (x : Nat) → x = x := by
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
{"title": "hello world",
|
||||
"kind": "quickfix",
|
||||
"edit":
|
||||
{"documentChanges": [],
|
||||
"changes":
|
||||
{"file://codeaction.lean":
|
||||
[{"range":
|
||||
{"start": {"line": 18, "character": 4},
|
||||
"end": {"line": 18, "character": 4}},
|
||||
"newText": "hello!!!"}]},
|
||||
"changeAnnotations": {}},
|
||||
"data": {"uri": "file://codeaction.lean"}}
|
||||
{"documentChanges":
|
||||
[{"textDocument": {"version": 0, "uri": "file://codeaction.lean"},
|
||||
"edits":
|
||||
[{"range":
|
||||
{"start": {"line": 17, "character": 4},
|
||||
"end": {"line": 17, "character": 4}},
|
||||
"newText": "hello!!!"}]}],
|
||||
"changes": {},
|
||||
"changeAnnotations": {}}}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue