fix: server: go to type definition

This commit is contained in:
Sebastian Ullrich 2021-04-08 18:54:53 +02:00
parent c7e6c9d89c
commit f75ce86f71
3 changed files with 19 additions and 1 deletions

View file

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

View file

@ -0,0 +1,6 @@
inductive Foo where
| foo
example : Foo :=
let c := Foo.foo
c
--^ textDocument/typeDefinition

View 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}}}]