fix: server: go to type definition
This commit is contained in:
parent
c7e6c9d89c
commit
f75ce86f71
3 changed files with 19 additions and 1 deletions
|
|
@ -414,7 +414,10 @@ section RequestHandling
|
|||
(notFoundX := pure #[]) fun snap => do
|
||||
for t in snap.toCmdState.infoState.trees do
|
||||
if let some (ci, Info.ofTermInfo i) := t.hoverableInfoAt? hoverPos then
|
||||
let expr ← if goToType? then ci.runMetaM i.lctx <| Meta.inferType i.expr else i.expr
|
||||
let mut expr := i.expr
|
||||
if goToType? then
|
||||
expr ← ci.runMetaM i.lctx do
|
||||
Meta.instantiateMVars (← Meta.inferType expr)
|
||||
if let some n := expr.constName? then
|
||||
let mod? ← ci.runMetaM i.lctx <| findModuleOf? n
|
||||
let modUri? ← match mod? with
|
||||
|
|
|
|||
6
tests/lean/interactive/definition.lean
Normal file
6
tests/lean/interactive/definition.lean
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
inductive Foo where
|
||||
| foo
|
||||
example : Foo :=
|
||||
let c := Foo.foo
|
||||
c
|
||||
--^ textDocument/typeDefinition
|
||||
9
tests/lean/interactive/definition.lean.expected.out
Normal file
9
tests/lean/interactive/definition.lean.expected.out
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
{"textDocument": {"uri": "file://definition.lean"},
|
||||
"position": {"line": 4, "character": 2}}
|
||||
[{"targetUri": "file://definition.lean",
|
||||
"targetSelectionRange":
|
||||
{"start": {"line": 0, "character": 10}, "end": {"line": 0, "character": 13}},
|
||||
"targetRange":
|
||||
{"start": {"line": 0, "character": 0}, "end": {"line": 1, "character": 7}},
|
||||
"originSelectionRange":
|
||||
{"start": {"line": 4, "character": 2}, "end": {"line": 4, "character": 3}}}]
|
||||
Loading…
Add table
Reference in a new issue